Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra Rerun on page switch #9

Open
3 of 4 tasks
danrom12 opened this issue May 23, 2024 · 0 comments
Open
3 of 4 tasks

Extra Rerun on page switch #9

danrom12 opened this issue May 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@danrom12
Copy link

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

It appears that when using the navigation bar, there is an extra re-run that is triggered when rendering for the first time. For example - if I am on page 'home' and navigate to 'page 1' - in my terminal i notice that if I am printing anything it prints twice.

Reproducible code example

###home.py
import streamlit as st
from streamlit_navigation_bar import st_navbar


st.set_page_config(initial_sidebar_state="collapsed")

styles = {"div": {"max-width": "350px"}}  # Reduce the page names spacing.
page = st_navbar(["Home", "Page 1", "Page 2"], styles=styles)


if page == "Page 1":
    st.switch_page("pages/page_1.py")
if page == "Page 2":
    st.switch_page("pages/page_2.py")

print('last')
# Home content goes here, for example:
st.write("Foo")


### page 1
import streamlit as st
from streamlit_navigation_bar import st_navbar


st.set_page_config(initial_sidebar_state="collapsed")

styles = {"div": {"max-width": "350px"}}  # Reduce the page names spacing.
page = st_navbar(["Home", "Page 1", "Page 2"], selected="Page 1", styles=styles)


if page == "Home":
    st.switch_page("home.py")
if page == "Page 2":
    st.switch_page("pages/page_2.py")

print('check')

# Page 1 content goes here, for example:
st.write("Bar")

Steps to reproduce

Run the above code and watch your terminal as you switch pages

Expected behavior

My understanding is there would just be a single run on initiation.

Current behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version:
  • Streamlit Navigation Bar version:
  • Python version:
  • Operating System:
  • Browser:

Additional information

No response

@danrom12 danrom12 added the bug Something isn't working label May 23, 2024
@danrom12 danrom12 changed the title Extra Rerun on Render Extra Rerun on page switch May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant