问题描述
当用户单击浏览器后退/前进按钮时,我使用 redux-undo 来操作活动/非活动按钮状态。我的函数 changeButtonImage() 根据当前的 redux 状态更改活动/非活动菜单按钮图像。我卡住了,因为 mapStatetoProps 在重新渲染后更改为新值。但我需要从“浏览器后退按钮处理程序”调用 changeButtonImage()。我找到了一种调用 store geState() 的解决方法,但它是反模式的方式。请向我解释如何以正确的方式欺骗它。
-> console.log('goBack');
console.log(
'before',isClickItem // mapStatetoProps property
// store.getState().itemReducer.present.isClickItem //-> anti-pattern
);
onUndo();
console.log(
'after',isClickItem // --> nothing changes before re-render
// store.getState().itemReducer.present.isClickItem //-> change but anti-pattern
);
changeButtonImage(); // --> use before undo state
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)