-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.tsx
35 lines (29 loc) · 1016 Bytes
/
static.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 Static: 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 Static;