Code Monkey home page Code Monkey logo

Comments (9)

Vikingama avatar Vikingama commented on July 29, 2024

用户退出登陆时,跳转刷新页面

from react-keep-alive.

ShenChang618 avatar ShenChang618 commented on July 29, 2024

@704826318 或许可以看下这个例子 Control cache,文档中介绍了这个组件 ProviderProvider 中文文档)。

这个需求通过 <Provider> 组件实现,大致流程如下:

  1. 通过变量(可以是 state 或者 redux 等数据管理工具的数据)设置 <Provider>include 或者 exclude 属性,需要注意 includeexclude 只能使用一个。
  2. 在切换到用户登录界面时,更改变量的值,例如使用的是 include 属性,那么就在变量中把需要缓存的页面去掉,这样下次再进入时,页面就没有缓存了。

更加详尽的代码可以看我上面的示例。😄

from react-keep-alive.

ShenChang618 avatar ShenChang618 commented on July 29, 2024

@Vikingama 刷新页面可能体验不会很好,优化可以考虑上面的回答😃

from react-keep-alive.

donglinkai avatar donglinkai commented on July 29, 2024

@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.

ShenChang618 avatar ShenChang618 commented on July 29, 2024

@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.

donglinkai avatar donglinkai commented on July 29, 2024

作者我又发现一个问题,一个页面被设置了disabled={true} ,页面是取消了缓存,但是页面内的子组件state数据还存在缓存问题

from react-keep-alive.

ShenChang618 avatar ShenChang618 commented on July 29, 2024

作者我又发现一个问题,一个页面被设置了disabled={true} ,页面是取消了缓存,但是页面内的子组件state数据还存在缓存问题

感谢提出问题😄,能给我发一份 DEMO 吗?我排查一下问题

from react-keep-alive.

donglinkai avatar donglinkai commented on July 29, 2024

作者我又发现一个问题,一个页面被设置了disabled={true} ,页面是取消了缓存,但是页面内的子组件state数据还存在缓存问题

感谢提出问题😄,能给我发一份 DEMO 吗?我排查一下问题

我知道问题了,是我的自己逻辑有问题😅

from react-keep-alive.

ShenChang618 avatar ShenChang618 commented on July 29, 2024

作者我又发现一个问题,一个页面被设置了disabled={true} ,页面是取消了缓存,但是页面内的子组件state数据还存在缓存问题

感谢提出问题😄,能给我发一份 DEMO 吗?我排查一下问题

我知道问题了,是我的自己逻辑有问题😅

嗯嗯,好哒😁

from react-keep-alive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.