-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update components via session_state #5690
Comments
Nope its not, Mine is pretty much a bug. Meaning if you use callbacks to update the session-state key, the custom component with that key does not update. At that point the app is essentially broken.
If the callback triggers, the component value does not update to False. This is true for all components I downloaded; I tried to play a bit to see if I can set the You basically need to decide if you
(Unless I am missing something strikingly obvious, which might be the case as well) |
Nope, also that one is different. Let me know if I should elaborate. |
@coolkau , so if I understand correctly, it seems you want to have custom components be able to update their session state value just like widgets and this currently doesn't work? Let me know if I understand it properly or where I am going wrong. |
No, let me try this again: Normally you would have a 2 way connection beween the the central store (e.g. redux) and the widget. In theory you dont need to push a change of the steamlit change to the componented state. You should get a new component after every change/rerun. However it seems that not the entire component is wiped when rerunning. This means the session state changes, but the component still has the state of the earlier run. I tried to find a way how to get updates from the steamlit state but did not find a way |
+1 for this issue.Hope streamlit can publish v2 custom component api,so that can change custom component value by session state. |
Problem
IT seems that the overall code style is to provide a default value to the widget or component. Then, after the first run, the value can be updated via the relevant key in the session_state.
Ie. I update
st.session_state["widget_key"]
via a callback. Then the widget will show the updated valueThis works with widgets. However, it is not clear how to achieve this with components. Components dont change the value, they will be out of sync with the session state.
I looked around none of the community components will upate; none of them is able to interact with other widgets via callbacks/ session_State. One widget solved this by having an explicit
value
parameter to update; this works but might not be the "streamlitty" way of doing things.Solution
Provide a way to pull the new stession_state into the react state upon re-rendering. If this exists, provide documentation or tutorials for this, as I did not manage to get this to work and it seems nobody else did (At least I did not find any example for this).
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.
The text was updated successfully, but these errors were encountered: