{"repo":"CJY0208/react-activation","free":true,"listed":false,"github":"https://github.com/CJY0208/react-activation","clone":"git clone https://github.com/CJY0208/react-activation.git","description":"Hack <KeepAlive /> for React","language":"JavaScript","stars":2030,"topics":["keepalive","react","cache-control","keep-alive","cache","offscreen"],"license":"MIT","category":"ui-components","readme_excerpt":"⚠️ NOTICE - DO NOT use - (React v18+) DO NOT use ReactDOMClient.createRoot , use ReactDOM.render instead, https://github.com/CJY0208/react-activation/issues/225#issuecomment-1311136388 or You can disable autoFreeze to work with createRoot though this may result in performance loss React Activation English 中文说明 HACK Implementation of the function in Vue For React Please also pay attention to official support in React 18.x --- More stable function with babel pre-compilation Online Demo --- More examples - Closable tabs with react-router - Closable tabs with umi - Using Animation with react-router --- Compatibility - React v16 / v17 / v18 - Preact v10+ - Compatible with SSR --- Install --- Usage 1. (Optional, Recommended) Add react-activation/babel plugins in .babelrc Why is it needed? The plugin adds a nk attribute to each JSX element during compilation to help the react-activation runtime generate an unique identifier by render location base on react-node-key . (0.11.0+) If you don't want to use Babel, it is recommended that each declare a globally unique and invariant cacheKey attribute to ensure the stability of the cache, as follows: 2. Wrap the components that need to keep states with Like the component in the example 3. Place the outer layer at a location that will not be unmounted, usually at the application entrance Note: When used with react-router or react-redux , you need to place inside or --- Lifecycle ClassComponent works with withActivation decorator Use componen","default_branch":null,"files":null,"tree":[],"storefront":"/r/CJY0208","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/CJY0208/react-activation/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}