Dave Hirschfeld
Dave Hirschfeld
SSolara
Created by Dave Hirschfeld on 3/17/2024 in #questions-issues
Trying to understand state management
If I have a reusable component with an internal state value = use_reactive(42) linked to an IntSlider and I have multiple of these components on my page, how do I then get the values of all nested slider components to e.g. use in another component? e.g.
@solara.component
def SliderComponent():
slider_value = solara.use_reactive(42)
solara.IntSlider('', slider_value.value, min=0, max=50)

@solara.component
def MyApp():
SliderComponent()
SliderComponent()

SomeComponentThatUsesTheValuesOfAllSliders()
@solara.component
def SliderComponent():
slider_value = solara.use_reactive(42)
solara.IntSlider('', slider_value.value, min=0, max=50)

@solara.component
def MyApp():
SliderComponent()
SliderComponent()

SomeComponentThatUsesTheValuesOfAllSliders()
6 replies