M
M
Maxim Korolsky2017-04-06 02:04:21
JavaScript
Maxim Korolsky, 2017-04-06 02:04:21

How to update a complex state?

case ACTIONS.GENERIC_SUCCESS:
      let datas = data.result.map(v => v.count);
      let lines = state[kind][id].data = datas;
     
      return Object.assign({}, state, {...lines});

There is such an action, promises return data to it.
datas - the same data.
The structure is as follows How to update data for different types and different id As soon as I haven’t tried it returns either the same data values ​​​​for all id (the last one that came) Or data is not overwritten at all
{lines: [kind]: [id]: data}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Frozen Coder, 2017-04-07
@frozen_coder

via $merge Immutability Helper try
https://facebook.github.io/react/docs/update.html
https://github.com/kolodny/immutability-helper

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question