S
SolidJS6mo ago
gsoutz

Untrack has no effect but signal doesn't fire anyway

Take a look at this way of events:
createEffect(() => {
console.log('fix fix', this.roundn[0]())
})

createEffect(() => {
let n =untrack(() => this.roundn[0]())

if (n) {
console.log('ok test', n.flop[0].card)
}
})


createEffect(() => {
let n = this.roundn[0]()

if (n) {
console.log('not test', n.flop[0].card)
}
})
createEffect(() => {
console.log('fix fix', this.roundn[0]())
})

createEffect(() => {
let n =untrack(() => this.roundn[0]())

if (n) {
console.log('ok test', n.flop[0].card)
}
})


createEffect(() => {
let n = this.roundn[0]()

if (n) {
console.log('not test', n.flop[0].card)
}
})
I trigger an event, and this is the console.log output:
not test 7h
not test 7h
I mean ok test doesn't happen because I untracked roundn() but roundn also doesn't happen because fix fix doesn't log.
5 Replies
gsoutz
gsoutzOP6mo ago
Here I've created a playground, but it works as expected, I honestly don't know what I am doing wrong. https://playground.solidjs.com/anonymous/fc02faf7-846a-44c5-a1d0-eeb6e69fc71f
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
gsoutz
gsoutzOP6mo ago
Here's a second playground more close to what I have: https://playground.solidjs.com/anonymous/8e4952d2-c5b1-4810-9d2e-d1d83b5bb5d6 The reason I tracked down this bug, and I think this is definitely a SolidJS bug. Is, because card0 doesn't trigger an effect, in my case, even though I set it with card1. So that's the main problem, though it triggers if I track another signal that doesn't actually fire.
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
gsoutz
gsoutzOP6mo ago
There you go, I reproduced it finally. https://playground.solidjs.com/anonymous/7dd7b03b-f58e-4e44-b86e-66ec439290b3. I think this is not a bug, but the code doesn't reach some paths to track the new values, how do you think I should fix this?
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
REEEEE
REEEEE6mo ago
Looks like it's working as expected You're setting the value of the signal inside the RoundN class the "fix fix" effect is listening to the roundn signal in the component not the one in the class the "ok test" effect won't run because it's not tracking the roundn signal and thus doesn't get notified that the signal contains the class instance What would you like to happen?
gsoutz
gsoutzOP6mo ago
Yes I understand my mistake now. Thank you no answer needed now. The main culprit of my mistake is, I set a signal with a class that contains other signals to be tracked, when the main signal changes, I still track the old inner signals in the code. I need to flatten down my design I figured. Thank you.
Want results from more Discord servers?
Add your server