具有动态参数的选择器未记录

时间:2019-01-13 21:06:01

标签: redux reselect

我正在尝试让Reselect记住我的带有动态参数的选择器

我的选择器:

import { createSelector, defaultMemoize } from 'reselect'

const allStatesSelector = store => store.state.states

export const getAllStates = createSelector(
  allStatesSelector,
  states => defaultMemoize(night => {
    console.log('getAllStates called with night:', night)
    const availableStates = night ? nightStates : dayStates
    return states.filter(state => availableStates.includes(state.id))
  }),
)

我这样称呼它:

states: getAllStates(store)(props.night)

选择器被调用1800次,而不是2次(考虑夜晚只能是对还是错)。

我想念什么?

0 个答案:

没有答案