Text_area's texts don't change once in two if we use the using session_state


I want to use the session_state’s texts to the text_area, but text_area’s texts don’t change once in two.

Steps to reproduce

  1. Run the below code.
  2. Write some texts in the text_area and Focus out
  3. Repeat No.2

Code snippet:

if 'test' not in st.session_state:
        st.session_state.test = ""
st.session_state.test = st.text_area("contents", st.session_state.test)

Expected behavior:

I want to get correct texts when the text_area’s texts change every time.

Debug info

streamlit 1.16.0
Python 3.9.12

1 Like

Use st.text_area("contents", key="test") instead (without the assignment).


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