Differences between: init-state vs: state at build function

I understand that you can initiate the state of a component by passing the map as the keyword value: init-state. But, passing this map as the value of the keyword: state, for example, between a component and its child component, can they now share the same state? This is it? Thanks.

+6
source share
1 answer

The difference is when the childs state is set.

  • :init-state set only once when the component is mounted.
  • :state set on each render.

Therefore :init-state should be used (as the name implies), initialize the state. On the other hand :state used to set a state that changes over time.

+5
source

Source: https://habr.com/ru/post/970576/


All Articles