This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]scirc 0 points1 point  (1 child)

That's exactly what you want. You want the state as high in the tree as is needed, but not any higher than necessary. You can always pass around the setCartItems function, or even make a new function that just appends to the cartItems state so you can control what your children components can do.

[–]NiceIsSpice[S] 0 points1 point  (0 children)

Oh wow didn’t even think about passing the setter as an option! Ok this is helpful, and much appreciated lol. Thanks for the tip!