S
Solara13mo ago
Soulscode

Component callback behavior

Is it expected for components to trigger the callback function on initial load?
4 Replies
MaartenBreddels
MaartenBreddels12mo ago
Can you be more specific? What callback and which component did you observe this in?
Soulscode
SoulscodeOP12mo ago
I've noticed this in all of the input components. I first noticed it in the checkbox component, where on first page load, it triggers the function associated with the on_value variable of the component, even though there's been no change(unless it considers initialization of the value as a change).
MaartenBreddels
MaartenBreddels12mo ago
do you have a code example for me?
Soulscode
SoulscodeOP12mo ago
The most basic of examples. If you run this and watch the terminal, you'll see the print statements in the callbacks trigger when the page loads, no change in initial state required. I had seen this originally on 1.22, but saw the same thing this morning after upgrading to 1.25. import solara as sol @sol.component def Page(): with sol.Card(): sol.Button('Click Me!', on_click=print('Clicked!')) sol.Select('Select Test', values=[0, 1, 2, 3, 4, 5], value=0, on_value=print('Value Selected!')) Having said this, when I throw some callback functions in there it works, and others it doesn't. I'm feeling like it's more of an understanding issue for me than a bug.
Want results from more Discord servers?
Add your server