implement scroll restoration
This commit is contained in:
7 files changed
+261
-75
No files matched your search
@@ -1,7 +1,7 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_router::prelude::*;
|
||||
use dioxus_router::{history::MemoryHistory, prelude::*};
|
||||
|
||||
fn main() {
|
||||
#[cfg(not(feature = "web"))]
|
||||
@@ -13,8 +13,16 @@ fn main() {
|
||||
fn App(cx: Scope) -> Element {
|
||||
use_router(
|
||||
&cx,
|
||||
&|| RouterConfiguration {
|
||||
..Default::default()
|
||||
&|| {
|
||||
#[cfg(not(feature = "web"))]
|
||||
let history = MemoryHistory::default();
|
||||
#[cfg(feature = "web")]
|
||||
let history = dioxus_router::history::WebHistory::new(None, true);
|
||||
|
||||
RouterConfiguration {
|
||||
history: Box::new(history),
|
||||
..Default::default()
|
||||
}
|
||||
},
|
||||
&|| {
|
||||
Segment::content(comp(Home))
|
||||
|
||||
@@ -188,16 +188,11 @@ pub struct RouterConfiguration {
|
||||
|
||||
impl Default for RouterConfiguration {
|
||||
fn default() -> Self {
|
||||
#[cfg(not(feature = "web"))]
|
||||
let history = Box::<MemoryHistory>::default();
|
||||
#[cfg(feature = "web")]
|
||||
let history = Box::<crate::history::WebHistory>::default();
|
||||
|
||||
Self {
|
||||
failure_external_navigation: comp(FailureExternalNavigation),
|
||||
failure_named_navigation: comp(FailureNamedNavigation),
|
||||
failure_redirection_limit: comp(FailureRedirectionLimit),
|
||||
history: history,
|
||||
history: Box::<MemoryHistory>::default(),
|
||||
on_update: None,
|
||||
synchronous: false,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user