我在我的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))
}
)
答案 0 :(得分:0)
从Immutable.js文档https://immutable-js.github.io/immutable-js/docs/#/get get
运算符无法以这种方式工作。
尝试使用它:
const getAllAppointments = state => get(state, 'allAppointments')
const getQuery = state => get(state, 'query')