javascript - 未定义“createPolyglotMiddleware”

标签 javascript reactjs redux react-redux polyglot

我正在尝试按照此处的说明设置 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/

相关文章:

node.js - 将 Node 模块导入 typescript/systemjs

mongodb - 关于 Redux 中的规范化

javascript - 过滤唯一字段值的数组

带有前导零的 Javascript parseInt()

reactjs - 如何在 React 中创建确认删除弹出窗口?

reactjs - React webpack 包的预加载动画

javascript - CSS(移动版网站)通过滑动滑动菜单

javascript - 2d 光线追踪 - 填充 View

javascript - 如何在 ReactJS 中为 li 元素添加事件类/状态?

reactjs - 以 Redux 状态存储 React 元素 : anti-pattern?