widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.65k stars 114 forks source link

hot-reload gives reactives a dict as value #510

Closed Jhsmit closed 3 months ago

Jhsmit commented 3 months ago

On solara 1.27 (not 1.26.1), when my app hot-reloads, the value of one of my Reactives is now a dict with value: {'solara-session-id': '394f6b57-6d9e-4875-be13-be4bfdcc0a73', 'theme': 'eyJ0aGVtZSI6ImxpZ2h0In0%3D.YF7SjbwEyaUmkh1IHz5Q9e3yBUVrr6A44GtYJbw%2F .... }

iisakkirotko commented 3 months ago

Hi @Jhsmit!

That dict looks an awful lot like a value solara.lab.cookies (exposed in https://github.com/widgetti/solara/pull/501) would take. Out of curiosity, what is the reactive variable that changes value called?

Jhsmit commented 3 months ago

yes I also found the dict to be a bit suspicious looking the reactive is called dataset_id

maartenbreddels commented 3 months ago

See https://github.com/widgetti/solara/pull/274 We solved it by giving the reactive variable in solara a stable fixed key. @iisakkirotko do you want to do a similar PR? These things are difficult to test btw, I think this is something we need to simply not forget. Any reactive variable in solara itself will not be reset on hot reload, which will mess up the other reactive variables.

Maybe, if we include the source file (where it is called from), in the key, these key collisions/stealings are less likely to happen.

iisakkirotko commented 3 months ago

@maartenbreddels I'll make a PR first thing tomorrow morning!