-
-
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.
- Better support for `App.getInitialProps` with `Page.getServerSideProps` and `Page.getStaticProps`
- Loading branch information
1 parent
f7db5d6
commit 20094b2
Showing
7 changed files
with
120 additions
and
29 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import Link from 'next/link'; | ||
import {useSelector} from 'react-redux'; | ||
import {NextPage} from 'next'; | ||
import {State} from '../components/reducer'; | ||
import {wrapper} from '../components/store'; | ||
|
||
interface OtherProps { | ||
getStaticProp: string; | ||
appProp: string; | ||
} | ||
|
||
const Other: NextPage<OtherProps> = ({appProp, getStaticProp}) => { | ||
const {app, page} = useSelector<State, State>(state => state); | ||
return ( | ||
<div className="static"> | ||
<p>Page has access to store even though it does not dispatch anything itself</p> | ||
|
||
<pre>{JSON.stringify({app, page, getStaticProp, appProp}, null, 2)}</pre> | ||
|
||
<nav> | ||
<Link href="/"> | ||
<a>Navigate to index</a> | ||
</Link> | ||
</nav> | ||
</div> | ||
); | ||
}; | ||
|
||
export const getStaticProps = wrapper.getStaticProps(({store}) => { | ||
store.dispatch({type: 'PAGE', payload: 'static'}); | ||
return {props: {getStaticProp: 'bar'}}; | ||
}); | ||
|
||
export default Other; |
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