How does solara determine when to rerender a widget?

I'm building a slightly more complex flow, and a widget I'm using doesn't refresh when I change a reactive variable it depends on. I have to manipulate the UI a bit for it to rerender. I'm not sure why this is happening. The relevant things to note are that I'm passing in the reactive state, and the widget only renders it. The state is a list of objects. For state ownership I tried a frozen dataclass + reducer, like in the calculator demo, and having the parent create state with use_reactive, and then pass it in to the child widget. Both result in the same behavior. Where can I read up on how this works? Is there a way to debug the widget's rendering dependencies?
1 Reply
victorminimal
victorminimal6mo ago
I ran a bunch of tests with the use_reactive option I added an on_change callback to use_reactive to just print to console on change when I set the value from the parent component, it works fine... but when I call .set in the child component, nothing happens I can see that the value was updated when the render eventually triggers, but the on_change callback doesn't trigger this is a bit weird... I'm not sure what to do to unblock this I tried a bunch of other things and I'm drawing blanks one question: can I pass reactive objects created with use_reactive to child components? will this work properly? or does the state need to be global for that to work? should I be using context instead? any help would be appreciated, please I figured it out, here it is for posterity it's not enough to call .set on the reactive variable - the object has to be different for lists it means a different instance you can't just modify the list and set it as the new value, it will be "smart" and not trigger redraw