evolution of a #react app

metamitya ·

evolution of a #react app

Replies

metamitya ·

each component maintains its own state

metamitya ·

child component does something that affects a parent or sibling so a setter function needs to be passed down from the parent to manipulate that parent's state so that the sybling can pull it from that common ancestor.

metamitya ·

parent or sibling changes state which is passed down through props but since component is keeping its own state, it now needs to getDerivedStateFromProps

metamitya ·

Now state lifted up to a parent component, all setters are "prop drilled" down.

metamitya ·

To prevent prop drilling entire components are passed down through the hierarchy with their own state to be rendered in a leaf node

metamitya ·

Why I decided to refactor @knovigator #react UI to use a single-state manager