Commit e3079187 authored by Fabrício Matté's avatar Fabrício Matté Committed by Tim Neutkens

Fix with-redux-saga server rendered clock, fixes #3760 (#3762)

Also updated the tick interval to one second, the clock works better this way and this is how the with-redux example is currently implemented as well.
parent 7d7deca1
......@@ -61,7 +61,7 @@ The second example, under `components/add-count.js`, shows a simple add counter
## What changed with next-redux-saga
The digital clock is updated every 800ms using the `runClockSaga` found in `saga.js`.
The digital clock is updated every second using the `runClockSaga` found in `saga.js`.
All pages are also being wrapped by `next-redux-saga` using a helper function from `store.js`:
......
import React from 'react'
import {increment, loadData, startClock} from '../actions'
import {increment, loadData, startClock, tickClock} from '../actions'
import {withReduxSaga} from '../store'
import Page from '../components/page'
class Counter extends React.Component {
static async getInitialProps ({store}) {
static async getInitialProps ({store, isServer}) {
store.dispatch(tickClock(isServer))
store.dispatch(increment())
if (!store.getState().placeholderData) {
store.dispatch(loadData())
......
import React from 'react'
import {increment, startClock} from '../actions'
import {increment, startClock, tickClock} from '../actions'
import {withReduxSaga} from '../store'
import Page from '../components/page'
class Counter extends React.Component {
static async getInitialProps ({store}) {
static async getInitialProps ({store, isServer}) {
store.dispatch(tickClock(isServer))
store.dispatch(increment())
}
......
......@@ -13,7 +13,7 @@ function * runClockSaga () {
yield take(actionTypes.START_CLOCK)
while (true) {
yield put(tickClock(false))
yield call(delay, 800)
yield call(delay, 1000)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment