TypeError: inputState.withMutations is not a function
Closed this issue · 9 comments
Hi,
Thanks for this amazing library.
But I have been getting this issue and unable to solve it.
TypeError: inputState.withMutations is not a function
src/combineReducers.js:22 19 | } 20 | } 21 | > 22 | return inputState 23 | ^ .withMutations((temporaryState) => { 24 | reducerKeys.forEach((reducerName) => { 25 | const reducer = reducers[reducerName];
I followed the docs and ended with the following configs:
// store.ts
import createSagaMiddleware from 'redux-saga';
import { createStore, compose, applyMiddleware } from 'redux';
import { createStateSyncMiddleware, initStateWithPrevTab } from 'redux-state-sync';
const sagaMiddleware = createSagaMiddleware();
const store = createStore(
rootReducer,
composeEnhancers(applyMiddleware(
sagaMiddleware,
createStateSyncMiddleware({}) // <-- Middleware added
))
);
initStateWithPrevTab(store); // <-- Initialised
sagaMiddleware.run(rootSaga);
export default store;
// reducer.ts
import { combineReducers } from 'redux-immutable';
import { withReduxStateSync } from 'redux-state-sync';
const rootReducer = combineReducers({
authentication,
configuration,
user,
});
export default withReduxStateSync(rootReducer); // <-- wrapped
Any help or suggestions towards solution would be greatly appreciated. Thanks!
I am using the following versions of libraries:
immutable: 4.0.0-rc.12
react: 16.12.0
react-dom: 16.12.0
react-redux: 7.1.3
redux-immutable: 4.0.0
redux-saga: 1.1.3
redux-state-sync: 3.0.0
Could you try to use the config below instead of {}
const config = {
// Map immutable object to js
prepareState: state => state.toJS(),
};
const store = createStore(
rootReducer,
composeEnhancers(applyMiddleware(
sagaMiddleware,
createStateSyncMiddleware(config) // <-- Middleware added
))
);
Still getting the same issue.
Just a FYI, createStateSyncMiddleware
accepts argument of type Config
but it is not updated to have prepareState
. I just @ts-ignored it for now. Thanks!
Thanks for the information. I will need some time to investigate this. I will most probably work on it this weekend. @godested Is this the same problem that you were facing?
@rahulpsd18 Please check the new release. Let me know if it works for you. Please close the issue if it works for you.
I'm going to close this first, please reopen it if the issue persists.
Still getting the same issue.
Still getting the same issue.
Did you followed the example that I created? Still the same error?
Okay, that's on me now. I did the changes in store but forgot the root reducer withReduxStateSync
changes.
Sorry 😬 and thanks a lot!
Hello @rahulpsd18
I am faced to this issue. can you provide me your solution?
Thanks