fix: Fix router synchronization with redux store

This commit is contained in:
Maksim Eltyshev
2022-12-15 01:34:48 +01:00
parent e28c06b85a
commit a858419f3c
19 changed files with 157 additions and 47 deletions
@@ -0,0 +1,28 @@
import { LOCATION_CHANGE_HANDLE } from './actions';
const createRouterReducer = (history) => {
const initialState = {
location: history.location,
action: history.action,
};
return (state = initialState, { type, payload } = {}) => {
if (type === LOCATION_CHANGE_HANDLE) {
const { location, action, isFirstRendering } = payload;
if (isFirstRendering) {
return state;
}
return {
...state,
location,
action,
};
}
return state;
};
};
export default createRouterReducer;