From f1fae6306418e68b47c1d2876101b64db3e518dd Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Thu, 8 Aug 2024 13:57:58 -0400 Subject: [PATCH] fix: only run Suspense on the condition in ProtectedRoute (closes #2798) --- router/src/components.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/router/src/components.rs b/router/src/components.rs index abed6b49a..aaff39477 100644 --- a/router/src/components.rs +++ b/router/src/components.rs @@ -331,12 +331,15 @@ where (view! { {move || { - match condition() { + let condition = condition(); + let view = view.clone(); + let redirect_path = redirect_path.clone(); + Unsuspend::new(move || match condition { Some(true) => Either::Left(view()), #[allow(clippy::unit_arg)] Some(false) => Either::Right(view! { }), None => Either::Right(()), - } + }) }}