Summary
I would like to get some value inside streamlit.components.v1.html and chatgpt recomend use Streamlit.setComponentValue but It maybe cannot use Streamlit.setComponentValue
for example code
Code snippet:
import streamlit as st
from streamlit.components.v1 import html
# Define the component's code
component_code = """
<div>
<button id="my-button">Click me</button>
<script>
const button = document.getElementById('my-button');
button.addEventListener('click', () => {
// Send the value to the Streamlit app
const value = 'Hello from the component';
Streamlit.setComponentValue(value);
});
</script>
</div>
"""
# Render the component and get the value sent back
component_value = html(component_code)
# Display the value returned from the component
st.write("Value returned from the component:", component_value)
If applicable, please provide the steps we should take to reproduce the error or specified behavior.