Created
May 17, 2020 20:54
-
-
Save johnpolacek/41a5a54f377e2ed5ae6463c91f67f863 to your computer and use it in GitHub Desktop.
Moving your context providers into _app.js prevents re-rendering of your context consuming components when navigating between pages in Next.js.
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 { ThemeProvider } from "theme-ui" | |
import theme from "../components/theme" | |
import { UserProvider } from "../components/context/UserContext" | |
function MyApp({ Component, pageProps }) { | |
return ( | |
<ThemeProvider theme={theme}> | |
<UserProvider user={pageProps.user}> | |
<Component {...pageProps} /> | |
</UserProvider> | |
</ThemeProvider> | |
) | |
} | |
export default MyApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment