
https://github.com/shenjunru/react-fiber-keep-alive
npm install --save react-fiber-keep-alive React Fiber 和 React Hooks。class component 生命周期。function component 的 hooks。context 变化。keep-alive。react-dom v16.8+ / v17 / v18 。import React from 'react'; import ReactDOM from 'react-dom'; import KeepAlive from 'react-fiber-keep-alive'; const root = document.getElementById('root'); ReactDOM.render(( <KeepAlive.Provider value={root}> ... <KeepAlive name="test"> <YourComponent /> </KeepAlive> ... </KeepAlive.Provider> ), root); 目前版本 0.6.2, 欢迎试用,提 bug
1 luffy Jun 14, 2022 这里的应用场景是什么? 什么情况下需要你这个库 |
2 sunburst112 Jun 14, 2022 @luffy 多 tab 栏切换缓存上一个 tab 组件的状态 类似 vue 的 keep-alive |
3 sunburst112 Jun 14, 2022 可以直接包裹 router6 的 outlet 实现效果吗? |
4 monexus OP @sunburst112 目前没用过 react-router6 ,你可以尝试一下,加几行代码而已 |
6 weeshin Jun 14, 2022 React 18 不是说要添加这个原生功能了? |