[✨] Conditional hooks #139
wmertens
started this conversation in
Proposals For Qwik
Replies: 2 comments
-
|
Another use case: run a visible task only when a condition is true. That way there's no JS loading on the client if it's not needed. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
We moved this issue to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem?
Sometimes you have to run a hook even if you know you don't need it, using resources for no reason.
Describe the solution you'd like
How about a hook that starts a deeper context and that optionally runs?
e.g.
And within each callback the rules of hooks still apply
So useConditional here makes a new signal or returns the given one.
It creates 2 hook contexts that are filled in lazily. The callbacks run within one of the contexts.
Describe alternatives you've considered
You can work around it with child components etc, but that's pretty complex to do.
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions