Display and value mismatch with warning


I noticed that when I create multiple pages, widgets (selectbox, slider, multiselect) will have persistent values across pages, but renders/displays a default value. Overall, there is a mismatch between the value returned by the widget and what is displayed.

My work around for this was to set the widget’s default (which is either specified by index or value) to the state of the widget (st.session_state.key_name). It functions fine from my perspective, but I receive a warning:
β€œThe widget with key β€œlag” was created with a default value but also had its value set via the Session State API.”

How can I suppress this warning on contrarily is there a better way to handle my issue?


Hey @BeverlyAb,

Fisrt welcome to the Streamlit community! :tada: :partying_face: :star_struck: :star2: :tada: :partying_face:

Check out this post for the answer to your question (spoilers: remove the value default!)

Happy Streamlit-ing!