Properly implement wait_for_suspense
Wait_for_suspense now does not call flush_sync, making it appropriate for deferring effects on the server. Futures will still run on the server (as needed to progress suspense) but use_effect / and memo watchers will not run on the server
This commit is contained in:
11 files changed
+156
-86
No files matched your search
@@ -0,0 +1,16 @@
|
||||
use dioxus_core::prelude::*;
|
||||
use dioxus_signals::{CopyValue, Writable};
|
||||
|
||||
/// A hook that uses before/after lifecycle hooks to determine if the hook was run
|
||||
pub fn use_hook_did_run(mut handler: impl FnMut(bool) + 'static) {
|
||||
let mut did_run_ = use_hook(|| CopyValue::new(false));
|
||||
|
||||
// Before render always set the value to false
|
||||
use_before_render(move || did_run_.set(false));
|
||||
|
||||
// Only when this hook is hit do we want to set the value to true
|
||||
did_run_.set(true);
|
||||
|
||||
// After render, we can check if the hook was run
|
||||
use_after_render(move || handler(did_run_()));
|
||||
}
|
||||
Reference in new issue
Block a user