Created
June 27, 2022 21:34
-
-
Save ruanlinos/c20b363802b455315bc1d597f6c8ce56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React, { ReactElement } from 'react'; | |
import { Provider } from 'react-redux'; | |
import { persistor, store } from '../store'; | |
import { PersistGate } from 'redux-persist/integration/react'; | |
import { Persistor } from 'redux-persist'; | |
export default function withProvider<T>( | |
WrapperComponent: React.FC<T>, | |
enhancedStore: any = store | |
): (props: T) => ReactElement { | |
const Gate = (PersistGate as unknown) as React.FC<{ persistor: Persistor }>; | |
return props => ( | |
<Provider store={enhancedStore}> | |
<Gate persistor={persistor}> | |
<WrapperComponent {...props} /> | |
</Gate> | |
</Provider> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment