Initializing store
I am having issues initializing the store with the createStore provided via readux-dynamic-modules. I am most certainly doing something wrong, but could not figure out what. Any help would be appreciated.
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Options: http://zalmoxisus.github.io/redux-devtools-extension/API/Arguments.html
actionCreators,
})
: compose;
enhancers.push(applyMiddleware(...middleware));
const enhancer = composeEnhancers(enhancers);
// With initial state
// ERROR: Uncaught (in promise) TypeError: Cannot read property 'concat' of undefined
const store = createStore(
reducers(history),
initialState,
enhancer,
[getSagaExtension({})],
);
// Without initial state
// Error: It looks like you are passing several store enhancers to createStore(). This is not supported
const store = createStore(
reducers(history),
// initialState,
enhancer,
[getSagaExtension({})],
);
It seems you are calling the createStore api incorrectly
You shouldn't pass reducers directly to createStore, but instead, create modules that you pass as the last arguments to the function.
See the todo-example in this repository for an example
@abettadapur hey!
I guess @eddievagabond faced with the same problem that I did.
I also tried just import the createStore from redux-dynamic-modules and was thinking it will work without any changes.
And the reason why I did it, because I have A LOT of reducers (and sagas), and transform each of them to the modules can be a pain. And thinking of this huge refactoring make me crying D:
Is there a way to make it easy?
You could create a single monolithic module that contains all your reducers and sagas and add that for now. Then you can refactor one by one as you go.
The whole purpose of the library is to modularize redux artifacts, so we only support module constructs
If you could just replace the createstore function with our implementation, you wouldn't gain any of the benefits of the library :/