Created
June 20, 2019 14:05
-
-
Save sibelius/26c6c6f673b4858c5f4669bfd1066edb to your computer and use it in GitHub Desktop.
withProviders helper utils
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
const App = () => { | |
return ( | |
<Providers> | |
<ClientRouter /> | |
</Providers> | |
); | |
}; |
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
const Providers = ({ children }: Props) => { | |
return ( | |
<ThemeProvider theme={theme()}> | |
<> | |
<GlobalStyledTheme /> | |
<I18nextProvider i18n={i18n}> | |
<SnackbarProvider>{children}</SnackbarProvider> | |
</I18nextProvider> | |
</> | |
</ThemeProvider> | |
); | |
}; |
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
export const withProviders = ({ initialEntries = ['/'], path, Component }) => props => { | |
return ( | |
<Providers> | |
<MemoryRouter initialEntries={initialEntries}> | |
<Route | |
path={path} | |
exact={true} | |
render={routeProps => { | |
return <Component environment={environment} {...routeProps} {...props} />; | |
}} | |
/> | |
</MemoryRouter> | |
</ConsoleProviders> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment