Recap
How do we define what is rendered on the browser ?
Here’s a summary of where we are right now.
- The function
_component_func—returned bydeclare_component—pings the component webserver for itsindex.htmlwith theCustomSlidercomponent code. - Arguments passed to
_component_funcare transferred toprops.argsforCustomSlider. This is specific to the React template and encoded withinwithStreamlitConnection. If you’re using another JS framework or vanilla Javascript, you will need to retrieve the arguments from within the JS event. - We pass those
propsto theSlidercomponent frombaseui, which acts as a stateless view of our component. Anything in the return statement ofCustomSlideris rendered on the web browser. - We initialize local state with an arbitrary value in our
CustomSlider - Each time you interact with the rendered slider, the value of the slider is stored in the state.
- The
keyargument prevents the slider from being remounted when props are changed or the script is rerun.
So we now have an interactive CustomSlider. The third part of the tutorial will dig into returning the state of the slider back into the Streamlit app.
