I
I
Ilya Soldatenkov2019-03-01 14:19:36
React
Ilya Soldatenkov, 2019-03-01 14:19:36

How to replace nested state in react and why is it bad?

Perhaps I misunderstand the nested state, but I understand that this is an object of this kind:

state = {
   phone: {
      countryCode,
      number
   }
}

So do bad practice? If so, what can replace such a structure?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Okhotnikov, 2019-03-01
@wrqqq

This is not bad, it's just not very convenient to update nested objects, I try to separate components and states whenever possible so that nested objects do not have to be stored.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question