Skip to content

Commit

Permalink
兼容 react-router 5.2.0;cacheKey 允许传递 Function 类型以提升可用性
Browse files Browse the repository at this point in the history
  • Loading branch information
CJY0208 committed May 26, 2020
1 parent 41e5177 commit fa4e8ed
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 1,131 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lib
node_modules
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
docs
node_modules
src
.babelrc
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default App
| when | `String` / `Function` | `"forward"` | Decide when to cache |
| className | `String` | - | `className` prop for the wrapper component |
| behavior | `Function` | `cached => cached ? { style: { display: "none" }} : undefined` | Return `props` effective on the wrapper component to control rendering behavior |
| cacheKey | `String` | - | For imperative control caching |
| cacheKey | `String` / `Function` | - | For imperative control caching |
| multiple (React v16.2+) | `Boolean` / `Number` | `false` | Allows different caches to be distinguished by dynamic routing parameters. When the value is a number, it indicates the maximum number of caches. When the maximum value is exceeded, the oldest updated cache will be cleared. |
| unmount (UNSTABLE) | `Boolean` | `false` | Whether to unmount the real dom node after cached, to save performance (Will cause losing the scroll position after recovered, fixed with `saveScrollPosition` props) |
| saveScrollPosition (UNSTABLE) | `Boolean` | `false` | Save scroll position |
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default App
| when | `String` / `Function` | `"forward"` | 用以决定何时使用缓存功能 |
| className | `String` | - | 作用于包裹容器上的样式类名 |
| behavior | `Function` | `cached => cached ? { style: { display: "none" }} : undefined` | 返回一个作用于包裹容器的 `props`,控制包裹容器的渲染方式 |
| cacheKey | `String` | - | 增加此属性用于命令式控制缓存 |
| cacheKey | `String` / `Function` | - | 增加此属性用于命令式控制缓存 |
| multiple (React v16.2+) | `Boolean` / `Number` | `false` | 允许按动态路由参数区分不同缓存,值为数字时表示最大缓存份数,超出最大值时将清除最早更新的缓存 |
| unmount (实验性) | `Boolean` | `false` | 缓存时是否卸载 dom 节点,用于节约性能(单独使用将导致恢复时滚动位置丢失,可配合 saveScrollPosition 修复) |
| saveScrollPosition (实验性) | `Boolean` | `false` | 用以保存滚动位置 |
Expand Down
Loading

0 comments on commit fa4e8ed

Please sign in to comment.