-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Hello,
I'm trying to replace connected-react-router by your library.
I'm using react-router-dom v6.
Everything looks fine but I got a problem when injecting new reducer in my store.
On each new reducer injected, LOCATION_CHANGE action is called.
I didn't have this issue with connected-react-router and react-router-dom v5.
Here is my code to reproduce the problem :
const {
createReduxHistory,
routerMiddleware,
routerReducer
} = createReduxHistoryContext({ history: createBrowserHistory() });
const reducers = {
...staticReducers,
router: routerReducer,
}
const createReducer = (staticReducers, addeddReducers) => combineReducers({ ...staticReducers, ...addeddReducers });
const store = configureStore({
reducer: reducers,
middleware: getDefaultMiddleware => {
return getDefaultMiddleware({
immutableCheck: false,
serializableCheck: false,
})
.concat(routerMiddleware)
},
});
store.asyncReducers = {};
store.injectReducer = (key, reducer) => {
store.asyncReducers[key] = reducer;
store.replaceReducer(createReducer(reducers, store.asyncReducers));
}
const history = createReduxHistory(store);
store.injectReducer("reducerToAdd", reducerToAdd);
const bootApplication = async () => {
const appRoot = createRoot(document.getElementById("root"));
appRoot.render(
<ReduxProvider store={store}>
<HistoryRouter history={history}>
NOTHING TO SEE
<Link to={"another/route"}>TEST</Link>
</HistoryRouter>
</ReduxProvider>
);
};
bootApplication();
Did I forgot something ?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels