S
SolidJS13mo ago
Shonty

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
lxsmnsyc13mo ago
you should use createEffect since onMount isn't reactive
thetarnav
thetarnav13mo ago
why would ref every return undefined in onMount though? at least in this simple example
Otonashi
Otonashi13mo 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