Created
March 2, 2020 12:52
-
-
Save radicalloop/5eee42366221416430ab54cd8e96e1dc to your computer and use it in GitHub Desktop.
Overwrite "App" component 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 React from 'react' | |
import { Provider } from 'react-redux' | |
import withRedux from 'next-redux-wrapper' | |
import { initStore } from '../store/store' | |
import App from 'next/app'; | |
const MyApp = props => { | |
const { Component, pageProps, store } = props | |
return ( | |
<Provider store={store}> | |
<Component {...pageProps} /> | |
</Provider> | |
) | |
} | |
MyApp.getInitialProps = async (appContext) => { | |
// calls page's `getInitialProps` and fills `appProps.pageProps` | |
const appProps = await App.getInitialProps(appContext); | |
return { ...appProps } | |
} | |
export default withRedux(initStore)(MyApp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment