Releases: kavience/react-keep-alive
Releases · kavience/react-keep-alive
修复缓存删除不干净的问题
add remove method
what ?
for solve issue StructureBuilder#82, I add remove method.
为了解决 issue StructureBuilder#82, 我添加了一个删除缓存的方法。
How to use ?
<KeepAliveProvider
ref={(ref) => {
this.keepAliveProviderRef = ref;
}}
max={30}
>
</KeepAliveProvider>First you need get keepAliveProviderRef, and in correct time call it's method named removeCache like this:
首先,需要获取 keepAliveProviderRef ,并在合适的时间调用名为 removeCache 的方法,如下所示:
keepAliveProviderRef.removeCache('KeepAlive');
// or
keepAliveProviderRef.removeCache(['KeepAlive']);removeCache receive string or string array as params which is name of KeepAlive.
removeCache 接收字符串或者是字符串数组作为参数,参数来源于 KeepAlive 的属性 name。
<KeepAlive name="KeepAlive">test<KeepAlive>Note
If you use react-router, and need use history.push when removeCache, you must use history.push first and then use removeCache.
如果你使用 react-router, 你必须在使用 removeCache 之前调用 history.push