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

Unexpected full refresh on navigation #777

Open
AMNRG opened this issue Jan 12, 2025 · 0 comments
Open

Unexpected full refresh on navigation #777

AMNRG opened this issue Jan 12, 2025 · 0 comments
Labels
A-router Area: router C-bug Category: bug, something isn't working

Comments

@AMNRG
Copy link
Contributor

AMNRG commented Jan 12, 2025

Describe the bug
Navigating between Home and Test results sometimes in a full refresh.

use sycamore::prelude::*;
use sycamore_router::{HistoryIntegration, Route, Router};

#[derive(Route, Copy, Clone)]
enum AppRoutes {
    #[to("/")]
    Home,
    #[to("/test")]
    Test,
    #[not_found]
    NotFound,
}

#[component]
fn App() -> View {
    view! {
        Router(
            integration=HistoryIntegration::new(),
            view=move |route: ReadSignal<AppRoutes>| {
                view! {
                    (match route.get() {
                        AppRoutes::Home => view! { "Home" Nav() },
                        AppRoutes::Test => view! { "Test" Nav() },
                        AppRoutes::NotFound => view! { "Not found" },
                    })
                }
            }
        )
    }
}

#[component]
pub fn Nav() -> View {
    view! {
        nav {
            ul {
                li { a(href="/") { "Home" } }
                li { a(href="/test") { "Test" } }
            }
        }
    }
}

fn main() {
    sycamore::render(App);
}

To Reproduce
Steps to reproduce the behavior:

  1. Click on Test.
  2. Click on Home => Unexpected full refresh.

Expected behavior
No full refresh when navigation between Home and Test.

Environment

  • Sycamore: main
@lukechu10 lukechu10 added C-bug Category: bug, something isn't working A-router Area: router labels Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-router Area: router C-bug Category: bug, something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants