我有一个非常标准的样板。基本上,我实现了Redux-persist并渲染加载屏幕,直到商店补水为止。
Store.js
const store = Reactotron.createStore(
reducers,
undefined,
compose(
applyMiddleware(ReduxThunk),
offline({
...offlineConfig,
persistCallback: () => Reactotron.log('HEY LOADED') //<<====How to update rehydrated state in App.js
})
)
);
App.js
import store from './Store';
export default class App extends Component {
state = { rehydrated: false };
...
render() {
if (!this.state.rehydrated) return <Loading />
return (
<Provider store={store}>
<MainNavigator />
</Provider>
)
}
基于上述设置,我可以看到商店成功补水后的日志记录。但是我想知道它如何更新App.js的状态?
答案 0 :(得分:0)
您可以实施PersistGate
来显示加载屏幕,直到检索到您的持久状态为止。如此处第二部分所述,https://github.com/rt2zz/redux-persist#basic-usage