SolidJSS
SolidJSโ€ข3y agoโ€ข
16 replies
nikiv.dev

How to have an effect that does not subscribe to the signal's values?

I have this effect: https://github.com/nikitavoloboev/kuskus/blob/main/src/components/Page.tsx#L15

  createEffect(() => {
    if (event()?.key === "Backspace") {
      setTodos(todos().filter((todo) => todo.id !== focusedTodo()))
    }
  })


Namely above code that when I press Backspace key, it enters into infinite loop that breaks the app.

The doc of the package says I should put it in effect however: https://www.npmjs.com/package/@solid-primitives/keyboard

So I am not sure how to get around this issue. Is there way to stop the subscribing to todos()?
image.png
Was this page helpful?