-
-
Notifications
You must be signed in to change notification settings - Fork 702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reactive tracking context warning needs to be more elaborate #2375
Comments
You mark two lines At least one of them is telling you that the way you"re accessing async fn load_data(count: ReadSignal<i32>, set_count: WriteSignal<i32>) {
let new_data = move || count() + 1;
set_count(new_data());
} This "looks" reactive (you"re doing I"m not totally sure what you"re trying to achieve here, or if this is a super simplified version of something else, but it seems like it would be much easier to do something like this: #[component]
pub fn BlockNumber() -> impl IntoView {
let (count, set_count) = create_signal(0);
let (interval, set_interval) = create_signal(500_u64);
let Pausable { .. } = use_interval_fn(
move || {
spawn_local(async move {
set_count(count.get_untracked() + 1);
})
},
interval,
);
view! {
<p>{move || count()}</p>
}
} |
Ok got it. Using get_untracked() |
The spans are sometimes broken by closures, because (afaik) you can"t use
On the other hand, the warning you post, without any context, looks pretty useful. These are all open source libraries, right? So if it"s giving you a reference for where a signal is defined in another library, you can look and see what that os. Ultimately this is just a linting and debugging tool that goes away in release mode. It isn"t perfect but it doesn"t need to be... it"s there to surface obviously wrong scenarios, and it works very well helping beginners fix misuses of the API in their own code. It"s always good to reduce false positives when possible but I don"t see a concrete issue here that can be addressed. |
Linking to rust-lang/rust#87417 |
Browser shows following warning for reactive tracking.
But its hard to debug by this warning.
Here is my code. Code works fine as expected, but not sure where the warning comes from.
The text was updated successfully, but these errors were encountered: