Is there a way to trigger Solid's createEffect using an external dependency, as with React's useEffect dependency array?
I want to call setShowMenu on location.pathname change.
const location = useLocation()
createEffect(() => {
    console.log(location.pathname) // << external dependency
    setShowMenu(false)
})
Until there's a better option, I'm using this as a workaround.
const location = useLocation()
createEffect(() => location.pathname && setShowMenu(false))
Perhaps you are looking for the on helper?
createEffect(
  on(
    () => location.pathname,
    () => setShowMenu(false)
  )
);
https://www.solidjs.com/docs/latest/api#on
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With