React Boilerplate:substate.get不是函数

时间:2018-03-01 05:36:38

标签: reactjs redux react-redux

这与substate.get() is not a function using React Boilerplate的问题相同,但我没有得到解决此问题的方法。

我想仅在一个文件中定义我的初始状态。这是初始化状态的正确方法。

在app.js中我添加了

const initialState = fromJS({
  cloud: [
    {
      machine_name: 'trust.zscaler.net',
      domain: 'Zscaler.net',
        },
      ],
    });
const history = createHistory();
const store = configureStore(initialState, history);

在我的container / selectors.js

const selectCloud = (state) => state.get('cloud');

const makeSelectCloudName = () => createSelector(
  selectCloud,
  (cloudState) => cloudState.get('domain')
);

在我的container / index.js

const mapStateToProps = createStructuredSelector({
  cloud: makeSelectCloudName(),
});

const mapDispatchToProps = (dispatch) => ({
  setCloud: (value) => {
    dispatch(setCloud(value));
  },
})

const withReducer = injectReducer({ key: 'cloud', reducer });
const withSaga = injectSaga({ key: 'cloud', saga });
const withConnect = connect(mapStateToProps, mapDispatchToProps);

export default compose(
  withReducer,
  withSaga,
  withConnect,
)(CloudSelect);

0 个答案:

没有答案