我正在使用redux-immutable
并且需要connect()
在我的组件中使用多个属性。
这是 gameStore 减速器的初始状态:
const initialState = Immutable.fromJS({
isPlaying: null,
level: 0,
remainTime: 120,
nextLevelUp: 40 ,
requiredGoods: CROISSANT_CHOCOLATE,
score: 0,
renderingObjects : [],
})
和组件connect()
:
@connect((state) => ({
renderingObjects: state.getIn(['gameStore', 'renderingObjects']).toJS(),
isPlaying: state.getIn(['gameStore', 'isPlaying']).toJS(),
}
))
但出现错误:
未捕获的类型错误:无法读取 null 的属性“toJS”
那有什么问题?