Menu between multipages - Calling st.rerun() within a callback is a no-op

Tried to create a on-change menu using

selected5 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
                            icons=['house', 'cloud-upload', "list-task", 'gear'],
                            on_change=update_new, key='menu_5', orientation="horizontal")

and call switch_model inside the callback function, which produced the warning: Calling st.rerun() within a callback is a no-op.
Anyway to overcome this?

As the error suggests, any function assigned to a callback cannot contain a rerun command. Callbacks are something that occur at the beginning of a page rerun. What is contained within your callback function?

The recommendation would be to rework the callback so that it does not contain a callback. It would help to have a minimal, reproducible, executable snippet to understand what is happening.

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