Answer the question
In order to leave comments, you need to log in
How to prevent store from being overwritten due to persist?
Hello.
I have a problem.
When I click on the back button in the browser, the url changes and the action is
dispatched
useEffect(() => {
const activeStep = screenSteps[screenSteps.length - 1];
if (
activeStep.localPath !== router.query.localPath &&
router.query.localPath
) {
dispatch(updateScreenStep('BACK'));
}
}, [router.query]);
export const updateScreenStep = (action: Action, stepData?: IStep) => ({
type: ResearchActionTypes.UPDATE_SCREEN_STEP,
payload: {
stepData,
action,
},
});
export const reduceUpdateScreenStep = (
state: IState,
payload: IScreenStepData
): any => {
const { action, stepData } = payload;
const newScreenData = [...state.screenSteps];
if (action === 'NEXT') newScreenData.push(stepData);
else newScreenData.pop();
return newScreenData;
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question