Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use History in redux actions #929

Open
SimoNonnis opened this issue Jan 12, 2022 · 2 comments
Open

Use History in redux actions #929

SimoNonnis opened this issue Jan 12, 2022 · 2 comments

Comments

@SimoNonnis
Copy link

I am in the process to upgrade to rect-router-6 and getting rid of browserHistory inside my redux /actions folder.
I am trying to use history using both ways presented here:

two-ways

but I get an error anyway:

Using own history instance:
own-istance

Importing browser history singleton:
singleton

Does anyone know if I am doing something wrong?

@Nantris
Copy link

Nantris commented Mar 30, 2022

What's your environment that document is not defined? You can try memory-history

@petrloukota
Copy link

petrloukota commented Jun 8, 2022

Use HistoryRouter instead of BrowserRouter:
import { unstable_HistoryRouter as HistoryRouter } from 'react-router-dom';
Then, you will be able to import history global object in redux thunk actions.
import history from 'history/browser'; // use history in thunk actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants