fix: <Redirect/> between nested routes at same level (#767)

This commit is contained in:
Greg Johnston 2023-03-30 16:28:32 -04:00 committed by GitHub
parent 97bbdf561a
commit f42568d262
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,10 +34,15 @@ where
if let Some(redirect_fn) = use_context::<ServerRedirectFunction>(cx) { if let Some(redirect_fn) = use_context::<ServerRedirectFunction>(cx) {
(redirect_fn.f)(&path); (redirect_fn.f)(&path);
} }
// redirect on the client // redirect on the client
let navigate = use_navigate(cx); else {
navigate(&path, options.unwrap_or_default()) let navigate = use_navigate(cx);
leptos::request_animation_frame(move || {
if let Err(e) = navigate(&path, options.unwrap_or_default()) {
leptos::error!("<Redirect/> error: {e:?}");
}
});
}
} }
/// Wrapping type for a function provided as context to allow for /// Wrapping type for a function provided as context to allow for