Commit 90b14acd authored by Shen Chang's avatar Shen Chang

Merge branch 'master' of github.com:Sam618/react-keep-alive

parents 1fec2530 4200f6a2
Copyright (c) 2019-2020 Shen Chang
Anti 996 License Version 1.0 (Draft)
Permission is hereby granted to any individual or legal entity
obtaining a copy of this licensed work (including the source code,
documentation and/or related items, hereinafter collectively referred
to as the "licensed work"), free of charge, to deal with the licensed
work for any purpose, including without limitation, the rights to use,
reproduce, modify, prepare derivative works of, distribute, publish
and sublicense the licensed work, subject to the following conditions:
1. The individual or the legal entity must conspicuously display,
without modification, this License and the notice on each redistributed
or derivative copy of the Licensed Work.
2. The individual or the legal entity must strictly comply with all
applicable laws, regulations, rules and standards of the jurisdiction
relating to labor and employment where the individual is physically
located or where the individual was born or naturalized; or where the
legal entity is registered or is operating (whichever is stricter). In
case that the jurisdiction has no such laws, regulations, rules and
standards or its laws, regulations, rules and standards are
unenforceable, the individual or the legal entity are required to
comply with Core International Labor Standards.
3. The individual or the legal entity shall not induce or force its
employee(s), whether full-time or part-time, or its independent
contractor(s), in any methods, to agree in oral or written form, to
directly or indirectly restrict, weaken or relinquish his or her
rights or remedies under such laws, regulations, rules and standards
relating to labor and employment as mentioned above, no matter whether
such written or oral agreement are enforceable under the laws of the
said jurisdiction, nor shall such individual or the legal entity
limit, in any methods, the rights of its employee(s) or independent
contractor(s) from reporting or complaining to the copyright holder or
relevant authorities monitoring the compliance of the license about
its violation(s) of the said license.
THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE
LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<h1 align="center">React Keep Alive</h1> <h1 align="center">React Keep Alive</h1>
<div align="center"> <div align="center">
[![npm](https://img.shields.io/npm/v/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![Travis (.org)](https://img.shields.io/travis/Sam618/react-keep-alive.svg?style=for-the-badge)](https://travis-ci.org/Sam618/react-keep-alive.svg?branch=master) [![license](https://img.shields.io/npm/l/react-keep-alive.svg?style=for-the-badge)](https://github.com/Sam618/react-keep-alive/blob/master/LICENSE) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![downloads](https://img.shields.io/npm/dm/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![typescript](https://img.shields.io/badge/language-typescript-blue.svg?style=for-the-badge)](https://www.typescriptlang.org/) [![npm](https://img.shields.io/npm/v/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![Travis (.org)](https://img.shields.io/travis/Sam618/react-keep-alive.svg?style=for-the-badge)](https://travis-ci.org/Sam618/react-keep-alive.svg?branch=master) [![LICENSE](https://img.shields.io/npm/l/react-keep-alive.svg?style=for-the-badge)](https://github.com/Sam618/react-keep-alive/blob/master/LICENSE.MIT) [![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg?style=for-the-badge)](https://github.com/Sam618/react-keep-alive/blob/master/LICENSE.996ICU) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![downloads](https://img.shields.io/npm/dm/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![typescript](https://img.shields.io/badge/language-typescript-blue.svg?style=for-the-badge)](https://www.typescriptlang.org/) [![996.icu](https://img.shields.io/badge/link-996.icu-red.svg?style=for-the-badge)](https://996.icu)
<p><a href="https://nodei.co/npm/react-keep-alive/"><img src="https://nodei.co/npm/react-keep-alive.png?downloads=true&downloadRank=true&stars=true"></a></p> <p><a href="https://nodei.co/npm/react-keep-alive/"><img src="https://nodei.co/npm/react-keep-alive.png?downloads=true&downloadRank=true&stars=true"></a></p>
...@@ -51,7 +51,7 @@ import Test from './views/Test'; ...@@ -51,7 +51,7 @@ import Test from './views/Test';
ReactDOM.render( ReactDOM.render(
<Provider> <Provider>
<KeepAlive key="Test"> <KeepAlive name="Test">
<Test /> <Test />
</KeepAlive> </KeepAlive>
</Provider>, </Provider>,
...@@ -142,7 +142,7 @@ npm install react-router@next react-router-dom@next ...@@ -142,7 +142,7 @@ npm install react-router@next react-router-dom@next
Children of `<KeepAlive>` will be cached, but we have to make sure that `<KeepAlive>` is inside `<Provider>`. Children of `<KeepAlive>` will be cached, but we have to make sure that `<KeepAlive>` is inside `<Provider>`.
#### Props #### Props
`key`: Key must exist and need to ensure that all `<KeepAlive>` keys under the current `<Provider>` are unique. `name`: Name must exist and need to ensure that all `<KeepAlive>` names under the current `<Provider>` are unique(1.2.0 added, Replace key).
`disabled`: When we don't need components for caching, we can disable it; the disabled configuration will only takes effect when the component's status changes from unactive to active. `disabled`: When we don't need components for caching, we can disable it; the disabled configuration will only takes effect when the component's status changes from unactive to active.
...@@ -175,7 +175,7 @@ class App extends React.Component { ...@@ -175,7 +175,7 @@ class App extends React.Component {
<div> <div>
<Switch> <Switch>
<Route path="/one"> <Route path="/one">
<KeepAlive key="One"> <KeepAlive name="One">
<One /> <One />
</KeepAlive> </KeepAlive>
</Route> </Route>
...@@ -224,7 +224,7 @@ class App extends React.Component { ...@@ -224,7 +224,7 @@ class App extends React.Component {
<div> <div>
<Switch> <Switch>
<Route path="/one"> <Route path="/one">
<KeepAlive key="One"> <KeepAlive name="One">
<One /> <One />
</KeepAlive> </KeepAlive>
</Route> </Route>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<h1 align="center">React Keep Alive</h1> <h1 align="center">React Keep Alive</h1>
<div align="center"> <div align="center">
[![npm](https://img.shields.io/npm/v/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![Travis (.org)](https://img.shields.io/travis/Sam618/react-keep-alive.svg?style=for-the-badge)](https://travis-ci.org/Sam618/react-keep-alive.svg?branch=master) [![license](https://img.shields.io/npm/l/react-keep-alive.svg?style=for-the-badge)](https://github.com/Sam618/react-keep-alive/blob/master/LICENSE) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![downloads](https://img.shields.io/npm/dm/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![typescript](https://img.shields.io/badge/language-typescript-blue.svg?style=for-the-badge)](https://www.typescriptlang.org/) [![npm](https://img.shields.io/npm/v/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![Travis (.org)](https://img.shields.io/travis/Sam618/react-keep-alive.svg?style=for-the-badge)](https://travis-ci.org/Sam618/react-keep-alive.svg?branch=master) [![LICENSE](https://img.shields.io/npm/l/react-keep-alive.svg?style=for-the-badge)](https://github.com/Sam618/react-keep-alive/blob/master/LICENSE.MIT) [![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg?style=for-the-badge)](https://github.com/Sam618/react-keep-alive/blob/master/LICENSE.996ICU) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![downloads](https://img.shields.io/npm/dm/react-keep-alive.svg?style=for-the-badge)](https://www.npmjs.com/package/react-keep-alive) [![typescript](https://img.shields.io/badge/language-typescript-blue.svg?style=for-the-badge)](https://www.typescriptlang.org/) [![996.icu](https://img.shields.io/badge/link-996.icu-red.svg?style=for-the-badge)](https://996.icu)
<p><a href="https://nodei.co/npm/react-keep-alive/"><img src="https://nodei.co/npm/react-keep-alive.png?downloads=true&downloadRank=true&stars=true"></a></p> <p><a href="https://nodei.co/npm/react-keep-alive/"><img src="https://nodei.co/npm/react-keep-alive.png?downloads=true&downloadRank=true&stars=true"></a></p>
...@@ -53,7 +53,7 @@ import Test from './views/Test'; ...@@ -53,7 +53,7 @@ import Test from './views/Test';
ReactDOM.render( ReactDOM.render(
<Provider> <Provider>
<KeepAlive key="Test"> <KeepAlive name="Test">
<Test /> <Test />
</KeepAlive> </KeepAlive>
</Provider>, </Provider>,
...@@ -144,7 +144,7 @@ npm install react-router@next react-router-dom@next ...@@ -144,7 +144,7 @@ npm install react-router@next react-router-dom@next
我们必须确保 `<KeepAlive>``<Provider>` 里面,这样 `<KeepAlive>` 的子组件才能被缓存。 我们必须确保 `<KeepAlive>``<Provider>` 里面,这样 `<KeepAlive>` 的子组件才能被缓存。
#### Props #### Props
`key``key` 必须存在并且需要确保当前 `<Provider>` 下的所有 `<KeepAlive>``key` 都是唯一的 `name``name` 必须存在并且需要确保当前 `<Provider>` 下的所有 `<KeepAlive>``name` 都是唯一的(1.2.0 新增,替换 `key`
`disabled`:当我们不需要缓存组件时,我们可以禁用它;禁用仅在组件从未激活状态变为激活状态时生效。 `disabled`:当我们不需要缓存组件时,我们可以禁用它;禁用仅在组件从未激活状态变为激活状态时生效。
...@@ -178,7 +178,7 @@ class App extends React.Component { ...@@ -178,7 +178,7 @@ class App extends React.Component {
<div> <div>
<Switch> <Switch>
<Route path="/one"> <Route path="/one">
<KeepAlive key="One"> <KeepAlive name="One">
<One /> <One />
</KeepAlive> </KeepAlive>
</Route> </Route>
...@@ -227,7 +227,7 @@ class App extends React.Component { ...@@ -227,7 +227,7 @@ class App extends React.Component {
<div> <div>
<Switch> <Switch>
<Route path="/one"> <Route path="/one">
<KeepAlive key="One"> <KeepAlive name="One">
<One /> <One />
</KeepAlive> </KeepAlive>
</Route> </Route>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment