我正在尝试按照此处的说明设置 redux-polyglot:https://www.npmjs.com/package/redux-polyglot
我的问题是,当我添加 const polyglotMiddleware = createPolyglotMiddleware(
部分时,我收到一条错误,告诉我它没有定义。我不知道哪里出了问题。可以有人帮忙吗?
这是我的 reducer 代码:
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;
最佳答案
我认为您忘记导入createPolyglotMiddleware
,请在模块顶部尝试以下操作:
import { polyglotReducer, createPolyglotMiddleware } from 'redux-polyglot';
关于javascript - 未定义“createPolyglotMiddleware”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44938934/