Improve the second example in the read write same scope warning (#3374)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-12-17 15:32:01 -08:00
1 parent c0e01f99af
commit df719241fa
1 file changed
+3 -3
+3 -3
View File
@@ -121,7 +121,7 @@ fn app() -> Element {
let mut count2 = use_signal(|| 0);
use_effect(move || {
count1.write(count2());
count1.set(count2());
});
}
2) Reading and Writing to the same signal in different scopes:
@@ -134,7 +134,7 @@ fn app() -> Element {
use_effect(move || {
// This effect both reads and writes to count
println!("{}", count());
count.write(count());
count.set(1);
});
}
@@ -145,7 +145,7 @@ fn app() -> Element {
let mut count = use_signal(|| 0);
use_effect(move || {
count.write(count());
count.set(1);
});
use_effect(move || {
println!("{}", count());