从不可变导入 get 方法但无法在我的选择器中读取
Import get method from immutable but cannot read in my selector
我在我的 React 项目中使用了 Immutable JS,我想在我的选择器文件中使用 get 方法,但它无法被我的 "getAllAppointments" 和 "getQuery" 函数识别。
import {createSelector} from 'reselect'
import {get} from 'immutable'
const getAllAppointments = state => state.get('allAppointments')
const getQuery = state => state.get('query')
export const getVisibleAppointments = createSelector(
getAllAppointments,
getQuery,
(appointment, query) => {
return (!query) ?
appointment :
appointment.filter(item => item.title.toLowerCase().includes(query))
}
)
来自 Immutable.js 文档 https://immutable-js.github.io/immutable-js/docs/#/get get
运算符不能那样工作。
尝试使用它:
const getAllAppointments = state => get(state, 'allAppointments')
const getQuery = state => get(state, 'query')
我在我的 React 项目中使用了 Immutable JS,我想在我的选择器文件中使用 get 方法,但它无法被我的 "getAllAppointments" 和 "getQuery" 函数识别。
import {createSelector} from 'reselect'
import {get} from 'immutable'
const getAllAppointments = state => state.get('allAppointments')
const getQuery = state => state.get('query')
export const getVisibleAppointments = createSelector(
getAllAppointments,
getQuery,
(appointment, query) => {
return (!query) ?
appointment :
appointment.filter(item => item.title.toLowerCase().includes(query))
}
)
来自 Immutable.js 文档 https://immutable-js.github.io/immutable-js/docs/#/get get
运算符不能那样工作。
尝试使用它:
const getAllAppointments = state => get(state, 'allAppointments')
const getQuery = state => get(state, 'query')