34 |
35 | ---
36 |
37 | ## 更多复杂示例
38 |
39 | - [可关闭的路由 tabs 示例](https://codesandbox.io/s/keguanbideyifangwenluyou-tab-shilikeanluyoucanshufenduofenhuancun-ewycx)
40 | - [可关闭的路由 tabs 示例(`umijs`)](https://codesandbox.io/s/umi-keep-alive-tabs-demo-knfxy)
41 | - [使用路由转场动画](https://codesandbox.io/s/luyouzhuanchangdonghuashili-jdhq1)
42 |
43 | ---
44 |
45 | ## 兼容性
46 |
47 | - React v16 / v17 / v18
48 |
49 | - Preact v10+
50 |
51 | - 兼容 SSR
52 |
53 | ---
54 |
55 | ## 安装
56 |
57 | ```bash
58 | yarn add react-activation
59 | # 或者
60 | npm install react-activation
61 | ```
62 |
63 | ---
64 |
65 | ## 使用方式
66 |
67 | #### 1. (可选,建议)babel 配置文件 `.babelrc` 中增加 `react-activation/babel` 插件
68 |
69 | [为什么需要它?](https://github.com/CJY0208/react-activation/issues/18#issuecomment-564360695)
70 |
71 | 该插件将借助 [`react-node-key`](https://github.com/CJY0208/react-node-key) 于编译阶段在各 JSX 元素上增加 `_nk` 属性,帮助 `react-activation` 在运行时**按渲染位置生成唯一的缓存 id 标识**
72 |
73 | ```javascript
74 | {
75 | "plugins": [
76 | "react-activation/babel"
77 | ]
78 | }
79 | ```
80 |
81 | (0.11.0+)如果不使用 babel,建议给每个 `count: {count}
103 | 104 |
399 |
400 | ---
401 |
402 | ## Breaking Change 由实现原理引发的额外问题
403 |
404 | 1. `
32 |
33 | ---
34 |
35 | ## More examples
36 |
37 | - [Closable tabs with `react-router`](https://codesandbox.io/s/keguanbideyifangwenluyou-tab-shilikeanluyoucanshufenduofenhuancun-ewycx)
38 | - [Closable tabs with `umi`](https://codesandbox.io/s/umi-keep-alive-tabs-demo-knfxy)
39 | - [Using Animation with `react-router`](https://codesandbox.io/s/luyouzhuanchangdonghuashili-jdhq1)
40 |
41 | ---
42 |
43 | ## Compatibility
44 |
45 | - React v16 / v17 / v18
46 |
47 | - Preact v10+
48 |
49 | - Compatible with SSR
50 |
51 | ---
52 |
53 | ## Install
54 |
55 | ```bash
56 | yarn add react-activation
57 | # or
58 | npm install react-activation
59 | ```
60 |
61 | ---
62 |
63 | ## Usage
64 |
65 | #### 1. (Optional, Recommended) Add `react-activation/babel` plugins in `.babelrc`
66 |
67 | [Why is it needed?](https://github.com/CJY0208/react-activation/issues/18#issuecomment-564360695)
68 |
69 | 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`](https://github.com/CJY0208/react-node-key).
70 |
71 | ```javascript
72 | {
73 | "plugins": [
74 | "react-activation/babel"
75 | ]
76 | }
77 | ```
78 |
79 | **(0.11.0+)** If you don't want to use Babel, it is recommended that each `count: {count}
101 | 102 |
389 |
390 | ---
391 |
392 | ## Breaking Change
393 |
394 | 1. `