Fix write on render warning with read only signal props (#3194)

This commit is contained in:
Evan Almloff 2024-11-13 10:48:43 -06:00 committed by GitHub
parent 128608f3b2
commit 21465390f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

5
Cargo.lock generated
View file

@ -12371,11 +12371,12 @@ dependencies = [
[[package]]
name = "warnings"
version = "0.2.0"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c672c7629eeed21c37d7a96ee9c0287b86a5e29b5730773117e4261d1a73ca"
checksum = "64f68998838dab65727c9b30465595c6f7c953313559371ca8bf31759b3680ad"
dependencies = [
"pin-project",
"tracing",
"warnings-macro",
]

View file

@ -142,7 +142,7 @@ manganis = { path = "packages/manganis/manganis", version = "0.6.0-alpha.4" }
manganis-core = { path = "packages/manganis/manganis-core", version = "0.6.0-alpha.4" }
manganis-macro = { path = "packages/manganis/manganis-macro", version = "0.6.0-alpha.4" }
warnings = { version = "0.2.0" }
warnings = { version = "0.2.1" }
# a fork of pretty please for tests - let's get off of this if we can!

View file

@ -52,7 +52,12 @@ impl<T: 'static, S: Storage<SignalData<T>>> ReadOnlySignal<T, S> {
/// Mark any readers of the signal as dirty
pub fn mark_dirty(&mut self) {
use crate::write::Writable;
_ = self.inner.try_write();
use warnings::Warning;
// We diff props while rendering, but we only write to the signal if it has
// changed so it is safe to ignore the warning
crate::warnings::signal_write_in_component_body::allow(|| {
_ = self.inner.try_write();
});
}
}