Skip to content

Instantly share code, notes, and snippets.

@pheew
Created February 25, 2019 13:37
Show Gist options
  • Save pheew/5b13f6093d97ba6e4090128e135a011f to your computer and use it in GitHub Desktop.
Save pheew/5b13f6093d97ba6e4090128e135a011f to your computer and use it in GitHub Desktop.
import * as React from 'react'
import { Persistor, persistStore } from 'redux-persist'
import { PersistGate } from 'redux-persist/integration/react'
const WithPersistGate = (Component) => (props) => {
if (!props.store.persistor) {
props.store.persistor = persistStore(props.store)
}
return (
<PersistGate persistor={props.store.persistor}>
<Component {...props} />
</PersistGate>
)
}
export default WithPersistGate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment