J
J
John Johnson2019-04-17 16:03:38
React
John Johnson, 2019-04-17 16:03:38

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

1 answer(s)
A
Anton Spirin, 2019-04-17
@Rocknrolla99

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 question

Ask a Question

731 491 924 answers to any question