Skip to content
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

v1.2更新说明 #8

Open
ckinmind opened this issue Feb 4, 2017 · 2 comments
Open

v1.2更新说明 #8

ckinmind opened this issue Feb 4, 2017 · 2 comments

Comments

@ckinmind
Copy link
Owner

ckinmind commented Feb 4, 2017

v1.2更新说明

  • 修改route相关
  • 修复页面快速切换,由于异步ajax导致setState报错的问题
  • 分离出item组件复用
@ckinmind
Copy link
Owner Author

ckinmind commented Feb 4, 2017

关于修改route相关

  1. 进入首页后会自动跳转到new页面,原来的代码没生效,我用IndexRedirect实现了这个需求
<IndexRedirect to="new" />

IndexRedirect用于访问根路由的时候,将用户重定向到某个子组件
参考资料:阮一峰:React Router 使用教程

@ckinmind
Copy link
Owner Author

ckinmind commented Feb 4, 2017

修复页面快速切换,由于异步ajax导致setState报错的问题

  1. 在issue ajax引发的问题(组件销毁前需要清除未完成的请求) #6 关于isMounted #4 中提到了这个错误的原因和解决办法
  2. 在这里我用了一个isUnmount来说明组件的状态,在每个ajax的回调里都要加这个判断,组件是否已经销毁了,如果销毁了就不再往下执行,否则如果有setState就会报错,因为组件已经被销毁,没法更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant