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

leaveFilter无法阻止页面跳转? #105

Open
zackchu opened this issue Jan 17, 2019 · 3 comments
Open

leaveFilter无法阻止页面跳转? #105

zackchu opened this issue Jan 17, 2019 · 3 comments

Comments

@zackchu
Copy link

zackchu commented Jan 17, 2019

我在页面中使用CacheLink进行页面的跳转和缓存,但是这里能不能跳转是由每个列表项循环出来的结果单独控制的,所以我希望不能跳转的项可以被leaveFilter阻止掉,但是我在路由配置的地方添加了leaveFilter后并没有达到预期的效果,第一个参数cb不管是否执行,页面都会进行跳转。

<HashRouter>
  <div>
    <Route name='rankitemdetail' path='teacher/detail/:code.html' component={RankItemDetail}/>
    <Route name='rankpage' path='teacher/rankpage.html' component={RankPage}
           leaveFilter={(cb, props) => {
             console.log('不会离开');
             console.log('leave', props);
             cb()
           }}
    />
    <Route cache name='homepage' path=':userType/homepage.html' component={HomePage}/>
  </div>
</HashRouter>

实际不是这么写的,但大体意思是这样。不知道是我配置方法不对还是别的原因?

@lanistor
Copy link
Owner

lanistor commented Jan 17, 2019

@zhshengchao thanks,这是一个待修复问题。需求收集

@andyyxw
Copy link

andyyxw commented Apr 5, 2019

@vifird 请问我想在表单验证通过后缓存当前页并跳转到下个页面,但是我在表单逻辑里面控制不了路由里的leaveFilter啊?
CacheLlik刚好满足我的需求,但是只能缓存上一个页面,我想缓存所有的上级页面,并在返回上一步的时候,清除所有下级页面的缓存。多级嵌套路由可以做到,但好像有性能问题,我想知道用React-keeper并且不用嵌套路由能做到吗?

@lanistor
Copy link
Owner

lanistor commented Apr 8, 2019

@andyyxw cache='parent'可以满足需求吗?

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

3 participants