[๐] Weird behavior when accessing props value in differents way
Wykks opened this issue ยท 3 comments
Which component is affected?
Qwik Optimizer (rust)
Describe the bug
I'm not sure how to describe it best, when accessing a value from a props in a specific way, Qwik behave differently on update, which in some case can crash the app if not expected.
Reproduction
https://stackblitz.com/edit/qwik-starter-usz5pr?file=src%2Froutes%2Fmy-stuff-modal.tsx
Steps to reproduce
See comments in repro
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.3 - /usr/local/bin/pnpm
npmPackages:
@builder.io/qwik: 1.5.2 => 1.5.2
@builder.io/qwik-city: 1.5.2 => 1.5.2
undici: 5.28.2 => 5.28.2
vite: 4.5.2 => 4.5.2
Additional Information
No response
can you explain exactly what errors you're getting? Also, try updating qwik-ui
If you open the modal then close it (click or esc key), there's this error (and then the app doesn't work anymore) :
props.stuff is undefined MyStuffModalContent_component_fooSig_useComputed_sBXmoQdQVq
stuff
is set to undefined
like this :
onClose$={() => {
stuffSig.value = undefined;
}
But this should not happen, because the modal component should be destroyed before being updated.
The weird part is that when reading stuff
like this :
const foo = props.stuff.foo;
return <div>{foo.foo2}</div>;
It doesn't work (props.stuff is undefined
on modal close).
But this doesn't throw any errors :
const stuff = props.stuff;
return <div>{stuff.foo.foo2}</div>;
Also the first case const foo = props.stuff.foo;
works if directly written in the main modal component.
This is a very short repro, it doesn't seems a big deal, bug with more code and more complicated models this can be hard to debug (at least for me, as I'm still not used to debug Qwik... quickly ๐ )
(Also qwik-ui updated, no changes)
@PatrickJS Can you elaborate a bit why this is "not planned" ? ๐
I believe this is a important issue in Qwik. Quite easy to workaround, but not that easy to debug. I spent hours to identify the bug and make that reproduction, I could have spend more hours to narrow it more but closing this like that is not motivating...