You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when working in NextJS, I have to write my own hydrate and reset function, please help to make it more friendly to dev
`
import { rootReducer } from 'fast-redux'
import { createWrapper, HYDRATE } from 'next-redux-wrapper'
import { applyMiddleware, createStore } from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import thunkMiddleware from 'redux-thunk'
when working in NextJS, I have to write my own hydrate and reset function, please help to make it more friendly to dev
`
import { rootReducer } from 'fast-redux'
import { createWrapper, HYDRATE } from 'next-redux-wrapper'
import { applyMiddleware, createStore } from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import thunkMiddleware from 'redux-thunk'
export const AppAction = {
RESET_APP: 'RESET_APP'
}
const appReducer = (state: any, action: any) => {
switch (action.type) {
case HYDRATE:
return {
...state, // use previous state
...action.payload // apply delta from hydration
}
case AppAction.RESET_APP:
return {}
default:
return rootReducer(state, action)
}
}
const initStore = () => {
return createStore(appReducer, composeWithDevTools(applyMiddleware(thunkMiddleware)))
}
export const withRedux = (component: React.ReactNode) => createWrapper(initStore).withRedux(component)
`
The text was updated successfully, but these errors were encountered: