mirror of
https://github.com/seigler/triplebyte-react-spa
synced 2025-07-26 23:26:10 +00:00
Initial commit from Create Next App
This commit is contained in:
commit
5684ef36ec
10 changed files with 7925 additions and 0 deletions
39
pages/index.js
Normal file
39
pages/index.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
import React from 'react'
|
||||
import { useDispatch } from 'react-redux'
|
||||
import { withRedux } from '../lib/redux'
|
||||
import useInterval from '../lib/useInterval'
|
||||
import Clock from '../components/clock'
|
||||
import Counter from '../components/counter'
|
||||
|
||||
const IndexPage = () => {
|
||||
// Tick the time every second
|
||||
const dispatch = useDispatch()
|
||||
useInterval(() => {
|
||||
dispatch({
|
||||
type: 'TICK',
|
||||
light: true,
|
||||
lastUpdate: Date.now(),
|
||||
})
|
||||
}, 1000)
|
||||
return (
|
||||
<>
|
||||
<Clock />
|
||||
<Counter />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
IndexPage.getInitialProps = ({ reduxStore }) => {
|
||||
// Tick the time once, so we'll have a
|
||||
// valid time before first render
|
||||
const { dispatch } = reduxStore
|
||||
dispatch({
|
||||
type: 'TICK',
|
||||
light: typeof window === 'object',
|
||||
lastUpdate: Date.now(),
|
||||
})
|
||||
|
||||
return {}
|
||||
}
|
||||
|
||||
export default withRedux(IndexPage)
|
Loading…
Add table
Add a link
Reference in a new issue