Skip to content

Commit

Permalink
Static to static navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-konshin committed Apr 16, 2020
1 parent 6dfdabb commit 67e6a53
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/demo-page/src/pages/other.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const OtherPage: NextPage<State> = () => {
<Link href="/">
<a>Navigate to index</a>
</Link>
<Link href="/other2">
<a>Navigate to other 2</a>
</Link>
</nav>
</div>
);
Expand Down
34 changes: 34 additions & 0 deletions packages/demo-page/src/pages/other2.tsx
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);

0 comments on commit 67e6a53

Please sign in to comment.