0

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;
Leo Farmer
  • 7,730
  • 5
  • 31
  • 47

1 Answers1

1

I think you have forgot to import createPolyglotMiddleware, try the following on top of you module:

import { polyglotReducer, createPolyglotMiddleware } from 'redux-polyglot';
GibboK
  • 71,848
  • 143
  • 435
  • 658
  • Yes, you are correct. Obvious when pointed out but I feel a bit grumpy that they don't have it in their documentation! – Leo Farmer Jul 06 '17 at 04:37