Hi
How do I rehydrate user inputs within a custom component from session_state
in a way where they are still editable?
Let’s take a custom my_component
that has user editable inputs in it, whose values are saved to session_state
with Streamlit.setComponentValue(value)
How do I properly pass that value back into the component (similarly to how native components like st.text_input
would be from session_state
)?
Here I’m trying to pass the value into the constructor when instantiating the component:
key = "key_0"
val = st.session_state.get(key, "")
returned_val = my_component(key=key, value=val)
if (returned_val): ut.update_query_params()
and that allows me to set the value of an input within my custom React component, for example:
<input key=key value=value />
With this technique, if the session_state value will correctly appear in the input
BUT then I can’t actually type in the field because the component constantly redraws with every keystroke!
What is the correct pattern?!
Thank you!!!