2020-05-25 18:21:35 +02:00
|
|
|
import { useEffect } from 'react'
|
|
|
|
import { useDispatch } from 'react-redux'
|
|
|
|
import { END } from 'redux-saga'
|
|
|
|
import { wrapper } from '../store'
|
2018-12-17 17:34:32 +01:00
|
|
|
import { loadData, startClock, tickClock } from '../actions'
|
2017-07-13 20:55:29 +02:00
|
|
|
import Page from '../components/page'
|
|
|
|
|
2020-05-25 18:21:35 +02:00
|
|
|
const Index = () => {
|
|
|
|
const dispatch = useDispatch()
|
2018-05-16 10:47:12 +02:00
|
|
|
|
2020-05-25 18:21:35 +02:00
|
|
|
useEffect(() => {
|
|
|
|
dispatch(startClock())
|
|
|
|
}, [dispatch])
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Page title="Index Page" linkTo="/other" NavigateTo="Other Page" />
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2017-07-13 20:55:29 +02:00
|
|
|
|
2020-05-25 18:21:35 +02:00
|
|
|
export const getStaticProps = wrapper.getStaticProps(async ({ store }) => {
|
|
|
|
store.dispatch(tickClock(false))
|
2017-07-13 20:55:29 +02:00
|
|
|
|
2020-05-25 18:21:35 +02:00
|
|
|
if (!store.getState().placeholderData) {
|
|
|
|
store.dispatch(loadData())
|
|
|
|
store.dispatch(END)
|
2017-07-13 20:55:29 +02:00
|
|
|
}
|
2020-05-25 18:21:35 +02:00
|
|
|
await store.sagaTask.toPromise()
|
|
|
|
})
|
2017-07-13 20:55:29 +02:00
|
|
|
|
2020-05-25 18:21:35 +02:00
|
|
|
export default Index
|