S
SolidJS2y ago
Tur

How to set delay on signal's setter

Hello! I'm trying to set a delay between mouseover and then menu opening. The menu is opened depending on signal state <li>on:mouseover={ setDropdownVisible('block') }</li> Once dropdownVisible() has set I set style display block on the menu I try to create the delay like this : <li>on:mouseover={ setTimeout(setDropdownVisible('block'), 1000) }</li> and it doesn't work. I guess this is a wrong way but what is right one and why?
5 Replies
Alex Lohr
Alex Lohr2y ago
GitHub
solid-primitives/packages/scheduled at main · solidjs-community/sol...
A library of high-quality primitives that extend SolidJS reactivity. - solid-primitives/packages/scheduled at main · solidjs-community/solid-primitives
Alex Lohr
Alex Lohr2y ago
also, <li onMouseOver={() => setDropDownVisible('block')}> please write correct JSX.
Tur
Tur2y ago
Why can't I just pass the setter withoyt wrapping it in a function&
thetarnav
thetarnav2y ago
try this. maybe incorrect syntax was the issue
<li onMouseOver={() => setTimeout(() => setDropDownVisible('block'), 1000)}>
<li onMouseOver={() => setTimeout(() => setDropDownVisible('block'), 1000)}>
Tur
Tur2y ago
Yes! It works, thank you!