0
jsがこのNextjsが
import {createStore, applyMiddleware, combineReducers} from 'redux'
import {composeWithDevTools} from 'redux-devtools-extension'
import withRedux from 'next-redux-wrapper'
import nextReduxSaga from 'next-redux-saga'
import createSagaMiddleware from 'redux-saga'
import {initialState} from './initialState'
import globalSaga from '../sagas/global'
const sagaMiddleware = createSagaMiddleware()
export function configureStore (reducers,initialState) {
console.log(initialState)
let states = {}
Object.keys(reducers).map((key) => {
states[key] = initialState[key]
})
console.log(reducers)
console.log(states)
const store = createStore(
combineReducers({reducers}),
states,
composeWithDevTools(applyMiddleware(sagaMiddleware))
)
store.sagaTask = sagaMiddleware.run(globalSaga)
return store
}
export function withReduxSaga (BaseComponent, reducers) {
return withRedux(configureStore(reducers,initialState))(nextReduxSaga(BaseComponent))
}
export default function configureWithReduxSaga(component,reducers){
return withReduxSaga(component,reducers)
}
のような店を初期化し、誤りがある
Store does not have a valid reducer. Make sure the argument passed to
makeStore is not a function
間違っているかもしれない何を、基本的に私は追加機能を書きたい減速とstore.global多くのコードなしでnextjsコンポーネントに特定のサガを使用すると、次のようなものが最適です。
configureWithReduxSaga(
{reducer1, reducer2},
{saga1, saga2}
)
は可能ですか?ルートレデューサーとルートサーガを作成して、すべてのコンポーネントに渡すことができます。これはコード化するのが難しくありませんが、それは実行可能ですか?