cdxcdx
cdxcdx
If React needs to hide the already visible content because it suspended again, it will clean up [layout Effects](https://react.dev/reference/react/useLayoutEffect) in the content tree. When the content is ready to be...
> 有点骚操作的意思哦,不过看起来是不是得完全自己控制该渲染哪个页面组件? 你可以看看这个https://github.com/yunsii/ant-design-pro-plus/issues/62#issuecomment-2132895723 同样的思路
https://github.com/IVLIU/react-offscreen
If React needs to hide the already visible content because it suspended again这里是hide而不是unmount
然后配合useEffectLayout可以知道页面再次显示
> 实现思路不一样吧,我之前的思路是缓存 Switch,直接通过路由跳转就可以切换了,到 React Router 6 我也想沿用这个思路。如果自行控制渲染组件的话,什么做法都可以了 😂 一样啊,我也是配合router来的
> 那 React Router 6 之后不是只能通过 useOutlet 拿到当前的页面组件了吗?我记得之前我看过源码,这个 hook 内部直接使用了 context,路由一改 outlet 就变了,没发缓存的。你是直接用的路由组件? 这样使用{outlet},只要offScreen没有被卸载,outlet怎么变化都被缓存,可以判断哪些路径不需要缓存就不要放在offscreen作为它的children
不同页面的,因为pathname变化了outlet也变化了
我现在已经用vue了,react越来越远