fn instance(properties: &Self::Properties) -> Signal<Self> {
let input_properties = properties;
let mut properties = use_signal(|| input_properties.clone());
let mut component = use_signal(|| Self::from_properties(input_properties.clone()));
use_effect(capture!(input_properties => move || { // line 35
if properties.read().to_owned() != input_properties {
*properties.write() = input_properties.clone(); // line 37
*component.write() = Self::from_properties(input_properties.clone());
}
}));
component
}
The code above is generating the following message:
WARN C:\Users\dangu\.cargo\registry\src\index.crates.io-6f17d22bba15001f\dioxus-signals-0.5.7\src\signal.rs:583 Write on signal at D:\dev\sensorial\systems\web-component\crates\web-component\src\web_component\mod.rs:37:29 finished in ReactiveContext created at D:\dev\sensorial\systems\web-component\crates\web-component\src\web_component\mod.rs:35:9 which is also subscribed to the signal. This will likely cause an infinite loop. When the write finishes, ReactiveContext created at D:\dev\sensorial\systems\web-component\crates\web-component\src\web_component\mod.rs:35:9 will rerun which may cause the write to be rerun again.HINT:This issue is caused by reading and writing to the same signal in a reactive scope. Components, effects, memos, and resources each have their own a reactive scopes. Reactive scopes rerun when any signal you read inside of them are changed. If you read and write to the same signal in the same scope, the write will cause the scope to rerun and trigger the write again. This can cause an infinite loop.
Since I am comparing input_properties to properties, I don't think it will run a infinite loop.
What would be the right way to implement this without triggering the warning?