Skip to content

Conversation

@kavience
Copy link

what ?

for solve issue #82, I add remove method.

为了解决 issue #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

@kavience kavience mentioned this pull request Sep 15, 2020
@kavience
Copy link
Author

kavience commented Sep 15, 2020

临时使用方法:

修改 react-keep-alive 版本为我的地址库

    ......
    "react-keep-alive-pro": "^2.5.5",
    ......

其它功能使用方法不变,仅添加一个 removeCache 方法。

@kavience kavience mentioned this pull request Oct 12, 2020
@Harres-hub
Copy link

How to force rerender (refresh) the keepalive component (page) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants