Comments (9)
用户退出登陆时,跳转刷新页面
from react-keep-alive.
@704826318 或许可以看下这个例子 Control cache,文档中介绍了这个组件 Provider(Provider 中文文档)。
这个需求通过 <Provider>
组件实现,大致流程如下:
- 通过变量(可以是 state 或者 redux 等数据管理工具的数据)设置
<Provider>
的include
或者exclude
属性,需要注意include
和exclude
只能使用一个。 - 在切换到用户登录界面时,更改变量的值,例如使用的是
include
属性,那么就在变量中把需要缓存的页面去掉,这样下次再进入时,页面就没有缓存了。
更加详尽的代码可以看我上面的示例。😄
from react-keep-alive.
@Vikingama 刷新页面可能体验不会很好,优化可以考虑上面的回答😃
from react-keep-alive.
@Vikingama 刷新页面可能体验不会很好,优化可以考虑上面的回答😃
ts里面会出现语法报错
作为表达式调用时,无法解析类修饰器的签名。
不能将类型“ForwardRefExoticComponent<Pick<any, string | number | symbol> & RefAttributes<{}>> & { contextType: Context<any> | undefined; getDerivedStateFromError: GetDerivedStateFromError<any, any> | undefined; }”分配给类型“typeof OrderList”。
类型“ForwardRefExoticComponent<Pick<any, string | number | symbol> & RefAttributes<{}>> & { contextType: Context<any> | undefined; getDerivedStateFromError: GetDerivedStateFromError<any, any> | undefined; }”提供的内容与签名“new (props: any): OrderList”不匹配。ts(1238)
import { bindLifecycle } from 'react-keep-alive';
@bindLifecycle
export default class OrderList extends PureComponent<any, any> {
from react-keep-alive.
@Vikingama 刷新页面可能体验不会很好,优化可以考虑上面的回答😃
ts里面会出现语法报错
作为表达式调用时,无法解析类修饰器的签名。 不能将类型“ForwardRefExoticComponent<Pick<any, string | number | symbol> & RefAttributes<{}>> & { contextType: Context<any> | undefined; getDerivedStateFromError: GetDerivedStateFromError<any, any> | undefined; }”分配给类型“typeof OrderList”。 类型“ForwardRefExoticComponent<Pick<any, string | number | symbol> & RefAttributes<{}>> & { contextType: Context<any> | undefined; getDerivedStateFromError: GetDerivedStateFromError<any, any> | undefined; }”提供的内容与签名“new (props: any): OrderList”不匹配。ts(1238) import { bindLifecycle } from 'react-keep-alive'; @bindLifecycle export default class OrderList extends PureComponent<any, any> {
已修复
from react-keep-alive.
作者我又发现一个问题,一个页面被设置了disabled={true}
,页面是取消了缓存,但是页面内的子组件state
数据还存在缓存问题
from react-keep-alive.
作者我又发现一个问题,一个页面被设置了
disabled={true}
,页面是取消了缓存,但是页面内的子组件state
数据还存在缓存问题
感谢提出问题😄,能给我发一份 DEMO 吗?我排查一下问题
from react-keep-alive.
作者我又发现一个问题,一个页面被设置了
disabled={true}
,页面是取消了缓存,但是页面内的子组件state
数据还存在缓存问题感谢提出问题😄,能给我发一份 DEMO 吗?我排查一下问题
我知道问题了,是我的自己逻辑有问题😅
from react-keep-alive.
作者我又发现一个问题,一个页面被设置了
disabled={true}
,页面是取消了缓存,但是页面内的子组件state
数据还存在缓存问题感谢提出问题😄,能给我发一份 DEMO 吗?我排查一下问题
我知道问题了,是我的自己逻辑有问题😅
嗯嗯,好哒😁
from react-keep-alive.
Related Issues (20)
- The onClick inside of <KeepAliveProvider /> not work in React 17 HOT 6
- 大佬,我想问下,该插件兼容redux吗?因为详情页面的数据,都是用的同一个字段,每次请求新的详情页面,都会替换之前的redux数据,关于该问题,您这边有解决方法吗?
- 你好,页面包裹KeepAlive之后,state改变,不会重新渲染组件。
- 更新state数据之后,通过props传递给下层组件,下层组件不会重新渲染。 HOT 1
- keep-alive在iframe场景下会失效 HOT 1
- Props aren't updating when wrapped in KeepAlive HOT 1
- onClick event is not working HOT 7
- hooks 中组件离开时,无法获取deactive组件的滚动距离
- 用了以后父子组件的props各种乱套,失效,已经放弃了 HOT 1
- useKeepAliveEffect dosent work HOT 3
- removeCache方法匹配key和name的bug HOT 1
- New implementation HOT 1
- 缓存后的组件,按钮点击等事件无效,这是怎么回事呢 HOT 8
- componentDidActivate Not implemented
- How to force rerender (refresh) the keepalive component (page) ?
- 使用KeepAlive包裹住组件后,里面的点击事件没有效果了 HOT 3
- Try react-fiber-keep-alive
- react-router-dom 6 以上,包裹后报错 HOT 1
- KeepAlive”不能用作 JSX 组件。 其元素类型 "ReactElement<any, any> | Component<IKeepAliveProps, any, any> | null" 不是有效的 JSX 元素。 不能将类型“Component<IKeepAliveProps, any, any>”分配给类型“Element | ElementClass | null”。 不能将类型“Component<IKeepAliveProps, any, any>”分配给类型“ElementClass”。 在这些类型中,"render()" 返回的类型不兼容。
- vite工程下,出现错误
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-keep-alive.