-
-
Notifications
You must be signed in to change notification settings - Fork 693
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
Improve reactive signal accessed outside reactive context
warning.
#3374
Comments
Note that I guess I'm open to the idea that there should be some special behavior here that differentiates Is this something you're interested in working on a PR to improve? |
Would be happy to give it a shot, but may need a lot of guidance, if that's okay for you. The first thing that comes to mind would be that any time we get into a "track outside of reactive context" state, we look at the stack frames below until we get back into a reactive context, then report those series of calls as the backtrace. Not sure how that would work or if it's the correct approach, so would love others' thoughts. |
I had thought about the |
@gbj, any thoughts on how to go about this before I dive in? |
I have not spent a lot of time thinking about it. I think it should be pretty straightforward though, and should not require the more-in-depth work described above.
leptos/reactive_graph/src/wrappers.rs Lines 375 to 380 in 28af33d
But it doesn't check whether you're in a reactive zone or not in its https://github.com/leptos-rs/leptos/blob/main/reactive_graph/src/wrappers.rs#L449-L468 As opposed to the (blanket) impl for other signal types, which does that check https://github.com/leptos-rs/leptos/blob/main/reactive_graph/src/traits.rs#L120-L146 So you'd mostly just want to add, in the |
[0.7]
Is your feature request related to a problem? Please describe.
When a signal is accessed outside a reactive context, the current warning displays the location of the signal access and where it was defined
e.g.
At app.rs:112:34, you access a `reactive_graph::signal::read::ReadSignal<bool>` (defined at app.rs:209:27) outside a reactive tracking context.
However, if a signal is accessed in a nested signal (e.g. via
Signal::derive
) where the nested signal is not in a reactive context, it is still the original signal that is referenced int he warning, not the derived signal.e.g.
Even though it is
(2)
causing theaccessed outside reactive context
warning, it is(1)
being referenced in the error.Describe the solution you'd like
The warning should reference the most immediate cause of being outside a reactive context, perhaps allowing for a backtrace to the signal causing the update as well.
e.g.
Describe alternatives you've considered
N/A
Additional context
Issue #3354 seems related, but different.
The text was updated successfully, but these errors were encountered: