I am struggling to understand why my code does not work. Am I misunderstanding something about session_state?
The code below starts fine, and I can press the button once to add text to the container. The second time I press the button I get this error message:
Bad message format
Bad ‘setIn’ index 4 (should be between [0, 2])
def write_to_container():
st.session_state.my_container.write("Hello from method")
st.button("Append to container", on_click=write_to_container)
if "my_container" not in st.session_state:
st.session_state["my_container"] = st.container(border=True)
st.session_state.my_container.write("Hello")
Streamlit version: 1.39.0
Python: 3.11.5