fix: never resolve LocalResource synchronously (closes #2736)
This commit is contained in:
parent
5fb80aaa40
commit
f2d6375d93
|
@ -18,6 +18,7 @@ server_fn = { workspace = true }
|
|||
tracing = { version = "0.1", optional = true }
|
||||
futures = "0.3"
|
||||
|
||||
any_spawner = { workspace = true }
|
||||
tachys = { workspace = true, optional = true, features = ["reactive_graph"] }
|
||||
|
||||
# serialization formats
|
||||
|
|
|
@ -48,6 +48,12 @@ impl<T> ArcLocalResource<T> {
|
|||
if cfg!(feature = "ssr") {
|
||||
pending().await
|
||||
} else {
|
||||
// LocalResources that are immediately available can cause a hydration error,
|
||||
// because the future *looks* like it is alredy ready (and therefore would
|
||||
// already have been rendered to html on the server), but in fact was ignored
|
||||
// on the server. the simplest way to avoid this is to ensure that we always
|
||||
// wait a tick before resolving any value for a localresource.
|
||||
any_spawner::Executor::tick().await;
|
||||
fut.await
|
||||
}
|
||||
}
|
||||
|
@ -198,6 +204,12 @@ impl<T> LocalResource<T> {
|
|||
if cfg!(feature = "ssr") {
|
||||
pending().await
|
||||
} else {
|
||||
// LocalResources that are immediately available can cause a hydration error,
|
||||
// because the future *looks* like it is alredy ready (and therefore would
|
||||
// already have been rendered to html on the server), but in fact was ignored
|
||||
// on the server. the simplest way to avoid this is to ensure that we always
|
||||
// wait a tick before resolving any value for a localresource.
|
||||
any_spawner::Executor::tick().await;
|
||||
fut.await
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue