Reputation: 1773
i have this initialState
const initialState = Immutable.fromJS({
list: [],
entities: {},
something: {
otherOne: false,
otherTwo: false,
},
});
and i want update the object something
with a function like this:
[UPDATE_SOMETHING]: (state, { key }) => { // <== key is the name of the nested props
return state.merge({
filterBy: {[key]: !state.get('key')},
});
),
but it does not work...how i can update the state dynamically?
Upvotes: 0
Views: 685
Reputation: 214
[UPDATE_SOMETHING]: (state, {key}) => {
const something = state.get('something').withMutations(s => {
s.set(key, !s.get(key));
});
return state.set('something', something);
),
Something like that could help?
Upvotes: 2