采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
如何清空redux,我退出的时候需要清空redux数据,不然下次用其他账号登陆app还是显示的上个用户的数据
这个问题很好,以咱们的课程为例:
这是我们的reducer/index.js
const index = combineReducers({ nav: navReducer, theme: theme, ... }); export default index;
那么,该如何清空store呢,比如我们要在用户登出的时候清空store,我们可以这样做:
const appReducer = combineReducers({ nav: navReducer, theme: theme, ... }); const rootReducer = (state, action) => { if (action.type === 'USER_LOGOUT') { state = undefined;//清空store } return appReducer(state, action) }; export default rootReducer;
登录后可查看更多问答,登录/注册
解锁React Native开发应用新姿势,React Native新版本热门技术
1.5k 2
1.1k 3
1.8k 4
1.8k 2
1.1k 1