It seems that on_change has no effect with the new Streamlit version. Your onChangeTest function is not called!
Anyway st.session_state[âtesting123â] contains the right value. Why programming like you did?
May be Iâm wrong, but it seems to me that the âStreamlit philosophyâ is rather to avoid callbacks.
x = st.button(âŠ)
if x:
âŠ
Why in your case, you donât have:
x = sac.chip( ⊠,key = âxxxxâ, âŠ)
if st.session_state.xxxx == âgoogleâ:
âŠ
if st.session_state.xxxx == âappleâ:
âŠ
Insert a line âprint(âxxxxâ)â into your callback function and you will see that it is not called in this latest version of Streamlit! I took your code and did it!
You should also discuss with the author of the âsacâ package and ask for their opinion.
the internal package structure has changed due to a refactoring; if you change the import in the streamlit_callback.py to from streamlit.components.v1 import custom_component as _components, it should work again. If you are not the author of sac, this might be something to bring to them.
That being written, this is not an official API we are going to guarantee from Streamlit-side However, we will look into this more closely and try to come up with a clean API for the future so that this patch is not needed anymore. In the meantime, I hope this^ unblocks you (for now).
Hey, thanks for the fix. But there seems to be some inconsistency in the result. I implemented it in my app and other custom components I built and at times, it does not seem to work. I know it was a hacky workaround but would have been nice to have had it.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking âAccept allâ, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.