我收到以下错误:substate is undefined。但是,我不确定为什么substate在我的选择器中未定义。有人可以帮我找出可能出问题的地方吗?

选择器:

import { createSelector } from 'reselect';

/**
 * Direct selector to the organization state domain
 */
const selectOrganizationDomain = () => (state) => state.get('organization');

/**
 * Other specific selectors
 */


/**
 * Default selector used by organization
 */

const selectOrganization = () => createSelector(
  selectOrganizationDomain(),
  (substate) => substate.toJS()
);

const selectChanges = () => createSelector(
  selectOrganization(),
  (substate) => substate.get('changes')
)

export default selectOrganization;
export {
  selectOrganizationDomain,
  selectChanges
};

最佳答案

您的selectOrganizationDomain应该是在状态下返回.get('organization')的函数:

const selectOrganizationDomain = state => state.get('organization');


您组成的选择器应该是createSelector调用的结果,其他选择器函数作为参数传递给createSelector

const selectOrganization = createSelector(
  selectOrganizationDomain,
  substate => substate.toJS()
);

const selectChanges = createSelector(
  selectOrganization,
  substate => substate.get('changes')
);

09-26 06:47