The goal is to click on a button that will activate a callback function. This function deals with data processing and utilizes the switch_page
function from streamlit-extras
to switch pages. However, a warning message appears stating that st.experimental_rerun()
is a no-op in the callback. I believe this is because the implementation of switch_page employs the st.experimental_rerun() function.
The callback function is crucial in my scenario since I employ a loop to generate the layout based on a list of data.
I’m wondering for this kind of use case, is there a solution or workaround?
Code snippet:
from streamlit_extras.switch_page_button import switch_page
num_data = len(data) # num_data=50
for i in range(num_data):
st.write(f"topic: {data[i]['title']}")
st.button(label="run",
key=current_payload['id'],
on_click=callback_func,
kwargs={"payload": data[i]["payload"], "value": data[i]["value"]})
def callback_func(payload, value):
# data processing
switch_page("demo")