Update session_state doesn't work when key is initialized

I’m trying to update a text box component value by updating the session_state

I’ve initialised it using

     n = int(st.text_input('Number of variants','2', key=benches.config["bench_type"]))

where the value inside benches.config["bench_type"] is statically stored as “sequential”.

and later I’m trying to update it as

	st.session_state.sequential = "5"

but I get the following error

    StreamlitAPIException: st.session_state.sequential cannot be modified after the widget with key sequential is instantiated.

Any help would be appreciated :slight_smile: Thanks!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.