Reputation: 7136
I have two sibling components, and the one on the left is changing the height. Its sibling on the right should change its height to the same size.
How do I accomplish something this in React?
Upvotes: 1
Views: 1320
Reputation: 4863
Here's how I would set it up:
thingyHeight
and set it to some default.mouseup
or something) that updates the value of 'thingyHeight` in the store.thingyHeight
to your right component.This is what people are referring to when they talk about 'declarative' programming. You are declaring how your component should know its height (by the thingyHeight
prop you pass it), you are not telling it how or when to change it's height (that's called imperative).
When the value changes in the store, React will re-render and set the new height if it needs to.
Upvotes: 2