【发布时间】:2017-07-19 18:40:07
【问题描述】:
我对 immutable.js 很陌生。
我要更新home.filmList[0].isDetailModalShow = false.
我该怎么做?
请帮我!
我的状态是这样的:
{
home: {
filmList: [
{
id: 1,
name: '111',
imgUrl: '111',
isDetailModalShow: false
},
{
id: 2,
name: '222',
imgUrl: '',
isDetailModalShow: false
},
]
}
}
和我的减速机这样
import { createReducer } from 'redux-act'
import { fromJS } from 'immutable'
import { setFilmList, toggleDetailModal } from './actions'
const initialState = fromJS({
filmList: [],
})
export default createReducer({
[toggleDetailModal]: (state, payload) => {
const index = state.get('filmList').findIndex(item => item.id === payload)
// state.get(filmList) is filmList: [........]
// below line code do not work!
return state.updateIn(['filmList', index, 'isDetailModalShow'], value => !value)
},
}, initialState)
【问题讨论】:
标签: reactjs redux immutable.js