react-router4 modal与动态路由的冲突

2017-11-30  本文已影响0人  fangdown

项目使用了
1,react-router4,
2,Bundle 动态加载路由
问题:
页面路由使用了动态路由,要实现一个modal层,即在当前路由页面打开一个新的路由,当这个路由是覆盖在原页面上,关闭新路由回到原路由,原路由不刷新,相当于modal 一样。
按官方代码示例
https://reacttraining.com/react-router/web/example/modal-gallery
实现后,发现在打开和关闭模态路由后,原路由会重新加载,影响体验
在多次的采坑实践后,解决方法:
const A = (props) => {
return (
<Bundle load={() => import('...A.jsx')}>
{(Comp) => { return <Comp {...props} />; }}
</Bundle>
);
};
更改成:
import A from '..A.jsx'后
问题解决。

上一篇 下一篇

猜你喜欢

热点阅读