Improve warnings when trying to update outside of pending suspense boundaries on the server (#2575)

* Improve warnings when trying to update outside of pending suspense boundaries on the server

* remove suspense resolve log
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-07-17 19:32:33 -07:00
1 parent 88af3e7eff
commit e794be5d78
14 files changed
+409 -313

No files matched your search

+10 -7
View File
@@ -418,13 +418,16 @@ impl<Args: 'static, Ret: 'static> Callback<Args, Ret> {
/// This borrows the callback using a RefCell. Recursively calling a callback will cause a panic.
pub fn call(&self, arguments: Args) -> Ret {
if let Some(callback) = self.callback.read().as_ref() {
Runtime::with(|rt| rt.push_scope(self.origin));
let value = {
let mut callback = callback.borrow_mut();
callback(arguments)
};
Runtime::with(|rt| rt.pop_scope());
value
Runtime::with(|rt| {
rt.with_scope_on_stack(self.origin, || {
let value = {
let mut callback = callback.borrow_mut();
callback(arguments)
};
value
})
})
.expect("Callback must be called from within the dioxus runtime")
} else {
panic!("Callback was manually dropped")
}