概述
> npm install redux-persist
npm install --save redux-persist-transform-filter
依赖
"redux-persist": "^6.0.0",
"redux-persist-transform-filter": "0.0.20",
src -----> app.js
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
const persistConfig = { key: 'root', storage, whitelist: ['regionInfo','urbanInfo','shopInfo','event'], // 配置白名单 里面写需要配置的名字 } // 数据持久化 const persistEnhancer = () => createStore => (reducer, initialState, enhancer) => { const store = createStore(persistReducer(persistConfig, reducer), initialState, enhancer); const persist = persistStore(store); return {...store, persist }; } export const dva = { config: { extraEnhancers: [persistEnhancer()] } }
最后
以上就是碧蓝刺猬为你收集整理的react 暂存数据持久化的全部内容,希望文章能够帮你解决react 暂存数据持久化所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复