-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
15,529 additions
and
11,195 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,39 @@ | ||
import React, {FC} from 'react'; | ||
import React from 'react'; | ||
import {Provider} from 'react-redux'; | ||
import {AppProps} from 'next/app'; | ||
import {wrapper} from '../store'; | ||
import App, {AppProps} from 'next/app'; | ||
import {fetchSystem, wrapper} from '../store'; | ||
|
||
const MyApp: FC<AppProps> = ({Component, ...rest}) => { | ||
interface PageProps { | ||
pageProps: { | ||
id: number; | ||
}; | ||
} | ||
|
||
const MyApp = ({Component, ...rest}: Omit<AppProps, 'pageProps'> & PageProps) => { | ||
console.log('rest: ', rest); | ||
const {store, props} = wrapper.useWrappedStore(rest); | ||
|
||
return ( | ||
<Provider store={store}> | ||
<h1>PageProps.id: {rest.pageProps.id}</h1> | ||
<Component {...props.pageProps} /> | ||
</Provider> | ||
); | ||
}; | ||
|
||
MyApp.getInitialProps = wrapper.getInitialAppProps(store => async (appCtx): Promise<PageProps> => { | ||
// You have to do dispatches first, before... | ||
await store.dispatch(fetchSystem()); | ||
|
||
// ...before calling (and awaiting!!!!) the children's getInitialProps | ||
const childrenGip = await App.getInitialProps(appCtx); | ||
return { | ||
pageProps: { | ||
// And you have to spread the children's GIP result into pageProps | ||
...childrenGip.pageProps, | ||
id: 42, | ||
}, | ||
}; | ||
}); | ||
|
||
export default MyApp; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.