I'm trying to set up redux-polyglot following the instructions here: https://www.npmjs.com/package/redux-polyglot
My problem is that when I add the const polyglotMiddleware = createPolyglotMiddleware(
part I get an error telling me it isn't defined. I can't work out where I've gone wrong. Can anyone help?
Here is my Reducer code:
import { createStore, combineReducers, applyMiddleware } from 'redux';
import { polyglotReducer } from 'redux-polyglot';
const rootReducer = combineReducers({
polyglot: polyglotReducer
});
const polyglotMiddleware = createPolyglotMiddleware(
'ACTION_TO_CATCH',
action => action.payload.locale,
locale => new Promise(resolve => {
// perform async here
resolve({
hello: 'bonjour',
});
}),
)
const store = createStore(rootReducer, {}, applyMiddleware(polyglotMiddleware));
export default store;
I think you have forgot to import createPolyglotMiddleware
, try the following on top of you module:
import { polyglotReducer, createPolyglotMiddleware } from 'redux-polyglot';