Answer the question
In order to leave comments, you need to log in
How to work with immutableJS correctly?
Hello. Tell me how best to solve such a case
. In the store, an array of USERS is stored with data in the immetabl format. An updated piece of data comes from the server.
Suppose {id:5,name:'Travis'}
I need to go through USERS to find the desired object by id and replace the data in it. how to do it with ImmutableJS methods?
Answer the question
In order to leave comments, you need to log in
const index = state.get('users').findIndex(user => user.get('id') === payload.user.id);
return state.setIn(['users', index], fromJS(payload.user));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question