Replies: 1 comment 1 reply
-
Issue regarding explicit tracking (which you can implement on your own): But the code can be made less verbose just by using the $effect(() => console.log(untrack(() => name) + count)) (You should rarely need |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Really sorry if this is a duplicate but quick question.
So $effect (()=>{}) runs when any of the used states that are used within the function are changed, unless you add a portion of the code that uses untrack(()=>{})
I am just wondering why we dont just say
$effect((var1,var2)=>{})
naming the vars/states that we want to trigger the effect.
I think this will lead to less verbose code when we want to reference the current value of some vars/states without triggering the effect when those states change
Like now I have this example :
$effect(()=>{
let actualName;
untrack(()=>actualName = name)
console.log(actualName + count)
})
Where both count and name are states
Beta Was this translation helpful? Give feedback.
All reactions