[英]How can I cache Redux states? (without redux-persist)
I want to save data in the store with Redux, like tokens and user-related data to be used across the whole application (I'm using React).我想使用 Redux 将数据保存在存储中,例如要在整个应用程序中使用的令牌和用户相关数据(我正在使用 React)。
The problem is that Redux does not persist in the state when refreshing a page.问题是 Redux 在刷新页面时不会保持状态。
Maybe I'm missing some core Redux or React concept?也许我错过了一些核心 Redux 或 React 概念? It feels a bit crazy for me not to be able to find a go-to package (or any other method) just to save a piece of data and be able to access it across the whole application without resetting on refresh :/无法找到一个首选包(或任何其他方法)只是为了保存一段数据并能够在整个应用程序中访问它而无需在刷新时重置:/
Redux-persist doesn't need to be very active - it works for half a decade now and there is just no need for a lot of changes. Redux-persist 不需要非常活跃——它现在可以工作五年,而且不需要进行很多更改。 It works.有用。
It is the to-go-package for that purpose.它是为此目的而准备的包。
尝试将您的 Redux 状态保存在 localStorage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.