remix-run/history

Use History in redux actions

SimoNonnis opened this issue · 2 comments

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?

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

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