Skip to content

Commit

Permalink
Ignore write while rendering warning in memo lazy recompute (#3647)
Browse files Browse the repository at this point in the history
  • Loading branch information
ealmloff authored Jan 27, 2025
1 parent bd30516 commit c850183
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/signals/src/memo.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::warnings::{signal_read_and_write_in_reactive_scope, signal_write_in_component_body};
use crate::write::Writable;
use crate::{read::Readable, ReadableRef, Signal};
use crate::{read_impls, GlobalMemo};
Expand All @@ -11,6 +12,7 @@ use std::{
use dioxus_core::prelude::*;
use futures_util::StreamExt;
use generational_box::{AnyStorage, BorrowResult, UnsyncStorage};
use warnings::Warning;

struct UpdateInformation<T> {
dirty: Arc<AtomicBool>,
Expand Down Expand Up @@ -179,7 +181,9 @@ where
let result = if needs_update {
drop(read);
// We shouldn't be subscribed to the value here so we don't trigger the scope we are currently in to rerun even though that scope got the latest value because we synchronously update the value: https://github.com/DioxusLabs/dioxus/issues/2416
self.recompute();
signal_read_and_write_in_reactive_scope::allow(|| {
signal_write_in_component_body::allow(|| self.recompute())
});
self.inner.inner.try_read_unchecked()
} else {
Ok(read)
Expand Down

0 comments on commit c850183

Please sign in to comment.