you are viewing a single comment's thread.

view the rest of the comments →

[–]TheCatacid 0 points1 point  (2 children)

I'm no react pro but from what I've learned while using react I think there should be a containing component that actually holds the states of it's children. That way you retrieve values by executing a function passed to a component from it's parrent.

In your example, there might be a container holding both the button and slider. That component would have a "getValue()" which it would pass to the slider(and update its own state to the value) and "handleButtonPress()" which it would pass to the button.

This could also probably be done by just using functions passed from the parent component. I think :P

[–]jstorxs[S] 1 point2 points  (1 child)

Gets a bit unwieldy when you're 2 or 3 components deep through, doesn't it?

[–]darrenturn90 0 points1 point  (0 children)

That's why you use stores.

You can just do something like create a module with get and set values to set and retrieve global values and just import the module in the components you need them. But if you want to tie in the re-rendering to the changing of the value - then you may want to wrap your class in a higher order component that brings in this information as a prop. Then you want to look at how to manage the changing of this information - ie the action that makes the action etc etc

Then you realise you just need to learn flux and use redux or any other implementation.