fix: suppress warning loading local resource without `<Suspense/>` in hydrate mode (closes #979) (#984)

This commit is contained in:
Greg Johnston 2023-05-03 11:22:34 -04:00 committed by GitHub
parent 9cf337309d
commit 6c763a83cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 11 deletions

View File

@ -842,17 +842,23 @@ where
_ = location;
}
#[cfg(all(feature = "hydrate", debug_assertions))]
crate::macros::debug_warn!(
"At {location}, you are reading a resource in `hydrate` mode \
outside a <Suspense/> or <Transition/>. This can cause \
hydration mismatch errors and loses out on a significant \
performance optimization. To fix this issue, you can either: \
\n1. Wrap the place where you read the resource in a \
<Suspense/> or <Transition/> component, or \n2. Switch to \
using create_local_resource(), which will wait to load the \
resource until the app is hydrated on the client side. (This \
will have worse performance in most cases.)",
);
{
if self.serializable != ResourceSerialization::Local {
crate::macros::debug_warn!(
"At {location}, you are reading a resource in \
`hydrate` mode outside a <Suspense/> or \
<Transition/>. This can cause hydration mismatch \
errors and loses out on a significant performance \
optimization. To fix this issue, you can either: \
\n1. Wrap the place where you read the resource in a \
<Suspense/> or <Transition/> component, or \n2. \
Switch to using create_local_resource(), which will \
wait to load the resource until the app is hydrated \
on the client side. (This will have worse \
performance in most cases.)",
);
}
}
}
let increment = move |_: Option<()>| {