New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何正确的清空某个路由下model中的数据 #1194
Comments
@hanxiansen
|
你这么做没啥问题,state 的变动肯定得走 reducer 。不过编辑、新增的逻辑走 modal 的话,数据可以不放 model 里,参考 https://github.com/dvajs/dva/blob/master/packages/dva-example-user-dashboard/ 的处理方式。 |
@sorrycc 发的链接404了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我现在在写一个编辑新闻的页面,因为编辑和新建都是一样的逻辑,所以我写在同一个页面中的,但问题是当我进入编辑逻辑时model中会残留着该次新闻编辑的model数据,当我下次以新建新闻的逻辑进来时就会把上次编辑新闻时的残留model数据加载进来,从而会影响到页面,我现在清空model的做法是在effects中写一个clearModel方法:
同时在reducer中新建一个clear方法:
然后在组件的componentWillUnMount中dispatch:
问下各位大佬,我这种写法有问题不?感觉这么写有点不妥啊。
The text was updated successfully, but these errors were encountered: