Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add remove cache method #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kavience wants to merge 6 commits into StructureBuilder:master
base: master
Choose a base branch
Loading
from kavience:master

Conversation

@kavience
Copy link

@kavience kavience commented Sep 15, 2020

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

zzzzzyuzhang reacted with thumbs up emoji
Copy link
Author

kavience commented Sep 15, 2020
edited
Loading

临时使用方法:

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

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

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

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /