forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade redux-persist from 4.10.2 to 5.10.0
redux-persist v5 introduces a couple breaking changes. These are described in detail in https://github.com/rt2zz/redux-persist/blob/master/docs/MigrationGuide-v5.md The most notable change is the removal of autoHydrate(). Additionally, redux-persist v5 clashes with redux-action-buffer which we use as well. redux-persist v5 has a somewhat different initialization flow than 4.10.2 and dispatches some new actions during initialization. This makes it incompatible with `redux-action-buffer`, because redux-action-buffer silently buffers all these actions which prevents the redux-dispatch init from completing. Therefore, get rid of `redux-action-buffer` and replace it with the new `PersistGate` that ships with redux-persist v5.
- Loading branch information
1 parent
1f9ad56
commit bf659a2
Showing
5 changed files
with
43 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
/* @flow */ | ||
import React, { PureComponent } from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { PersistGate } from 'redux-persist/lib/integration/react'; | ||
|
||
import type { ChildrenArray } from '../types'; | ||
import store, { restore } from './store'; | ||
import store, { persistor } from './store'; | ||
import timing from '../utils/timing'; | ||
import LoadingScreen from '../start/LoadingScreen'; | ||
|
||
type Props = { | ||
children: ChildrenArray<*>, | ||
}; | ||
|
||
export default class StoreHydrator extends PureComponent<Props> { | ||
componentDidMount() { | ||
timing.start('Store hydration'); | ||
restore(() => { | ||
timing.end('Store hydration'); | ||
}); | ||
} | ||
|
||
render() { | ||
return <Provider store={store}>{this.props.children}</Provider>; | ||
return ( | ||
<Provider store={store}> | ||
<PersistGate loading={<LoadingScreen />} persistor={persistor}> | ||
{this.props.children} | ||
</PersistGate> | ||
</Provider> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters