防止 React Native 快速刷新时 Redux 状态重置 (expo cli)

Den*_*nis 3 react-native react-redux

我试图了解如何将 React Native 快速刷新与 Redux 结合起来。我克隆了以下项目:https ://github.com/amandeepmittal/rnReduxhooks

当更改视图中的代码时,ViewNotes.js快速刷新效果很好。但是,当更改reducer中的代码时,notesApp.js 快速刷新会重置redux状态

我怎样才能防止这种情况发生?

有没有类似于 React 和 Redux 的 React Native 和 Redux 教程?(https://duske.me/setting-up-hot-module-replacement-with-create-react-app-and-redux/

动图

Den*_*nis 5

mycache我通过将每次更改的状态保存到新文件中定义的变量中来解决这个问题statecache.ts。创建商店时,我从该变量中获取状态。

因此,只有在编辑时才会重置状态statecache.ts,而在编辑减速器/视图时不会重置状态。

https://github.com/denniske/rnReduxhooks/commit/c2a0279927bf7c32b5f2507905ad146cff742770