I understand that you can initiate the state of a component by passing a map as the value of the :init-state keyword. But by passing this map as the value of the :state keyword, for example, between a component and its child component, now they can share that same state? Is that it? Thanks.
Differences between :init-state vs :state at build function
Asked Answered
The difference is when the childs state gets set.
:init-state
is only set once, when the component is mounted.:state
is set on each render.
Therefore, :init-state
should be used to (as the name suggests), initialise the state. On the other hand, :state
is used to set state that changes over time.
© 2022 - 2024 — McMap. All rights reserved.
om/set-state!
can be used for that purpose) – Ventriculus