Invalid persistent reducer to reinit
sinamics opened this issue · 3 comments
Hi
Im trying to switch database during runtime, but i keep getting
Invalid persistent reducer to reinit: reduxFormReducer
Can you please provide an example of how to implement this feature?
Reducer.js
import { persistentReducer} from 'redux-pouchdb-plus';
import { combineReducers } from 'redux';
import { routerReducer } from 'react-router-redux';
import { reducer as reduxFormReducer } from 'redux-form';
import PouchDB from 'pouchdb';
let dbChoice = 2;
const db = (reducerName, store, additionalOptions) => {
if (dbChoice === 1)
return new PouchDB('dbname1');
else
return new PouchDB('dbname2');
}
export default combineReducers({
form: persistentReducer(reduxFormReducer, {db}),
router: routerReducer
})
Dispatch from a connected component.
this.props.dispatch(reinit('reduxFormReducer'));
Hi Sinamics,
does it work with just calling reinit()
(to reinit all reducers)?
Could you also try to set a name for the persistent reducer explicitly (e.g. persistentReducer(reduxFormReducer, {name: 'custom-name', db});
). Does this work?
Hi
Calling reinit()
works, but it failed when adding a reducer name.
It also works when defining a name explicitly as your example.
I currently devolping another parth of my application, but will look into this issue in a few days.
I will keep you updated.