Problem with ref

Hi, I used to set ref like in this example, but it seems that when I use solidjs router, it doesn't work after unmounting and remounting the component (the ref return undefined). Is this normal behavior and should I use createEffect instead of onMount ?
3 Replies
lxsmnsyc
lxsmnsyc2y ago
you should use createEffect since onMount isn't reactive
thetarnav
thetarnav2y ago
why would ref every return undefined in onMount though? at least in this simple example
Otonashi
Otonashi2y ago
it shouldn't in this example, but if the router is causing it then it's because effects are being run immediately for some reason i guess assuming the component looks identical to this counter one reason i can think of is if it's being created outside a root, but that doesn't sound likely
Want results from more Discord servers?
Add your server