-
-
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
1 parent
6dfdabb
commit 67e6a53
Showing
2 changed files
with
37 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import {NextPage} from 'next'; | ||
import Link from 'next/link'; | ||
import {useSelector, useDispatch} from 'react-redux'; | ||
import {State} from '../components/reducer'; | ||
import {wrapper} from '../components/store'; | ||
|
||
export const getStaticProps = wrapper.getStaticProps(({store, previewData}) => { | ||
console.log('2. Page.getStaticProps uses the store to dispatch things'); | ||
store.dispatch({type: 'PAGE', payload: 'was set in other (SECOND) page ' + JSON.stringify({previewData})}); | ||
}); | ||
|
||
const OtherPage: NextPage<State> = () => { | ||
const {page} = useSelector<State, State>(state => state); | ||
const dispatch = useDispatch(); | ||
const bump = () => dispatch({type: 'BUMP'}); | ||
return ( | ||
<div className="other"> | ||
<p>Using Next.js default prop in a wrapped component.</p> | ||
<pre>{JSON.stringify({page}, null, 2)}</pre> | ||
<nav> | ||
<button onClick={bump}>bump</button> | ||
<Link href="/"> | ||
<a>Navigate to index</a> | ||
</Link> | ||
<Link href="/other"> | ||
<a>Navigate to other</a> | ||
</Link> | ||
</nav> | ||
</div> | ||
); | ||
}; | ||
|
||
export default wrapper.withRedux(OtherPage); |