2 ms·
Yeah there is a bit of a learning curve there. I was doing the same when I first started. It really depends on what you're trying to do, but it really comes do
by mfrye0 10y ago
Yeah there is a bit of a learning curve there. I was doing the same when I first started.
It really depends on what you're trying to do, but it really comes down to storing state and data in a central location.
If it's a simple component, passing the on click callback to a child that updates the parent master state is pretty straightforward. So for example selecting an item in a list and updating the active item when a list item is clicked.
If it's a really deeply nested component though, that can get a bit harder. I've had some success passing simple string values via the context reference, which makes the values accessible to all the children.
Another pattern I've used is having a state store similar to the flux pattern using eventemitter. I'm using this pattern a lot on thebigpicture.io for the editor page. There's two main columns in the page that are very deeply nested, so I created a separate state store and individual components are able to listen to changes from different events.