S
SolidJS4w ago
p2

"Show done" in a basic todo list, and handling reactive arrays

Trying to create a basic todo app to get my grips with some basic solid/reactivity principles. So far what I have works, but I have no idea if this is the idomatic way to handle array signals (ie if i'm changing/adding/removing elements the "correct") way. I will post the code as a separate message because it's too long. Additionally, how would I add some kind of filter to hide the tasks marked as done when the checkbox is clicked? I have tried a few approaches but none really did what i wanted.
4 Replies
p2
p2OP4w ago
p2
p2OP4w ago
No description
No description
peerreynders
peerreynders4w ago
if this is the idomatic way to handle array signals
For finegrained reactivity you would use a store instead. https://github.com/solidjs/solid-todomvc/blob/f48302376244513396de3e353e73ba136151b874/src/index.tsx#L37
add some kind of filter
Simply filter them before you pass them to the <For /> component. As the individual Todo records are referentially stable inside the store the DOM elements that are "kept" just stay where they belong. https://github.com/solidjs/solid-todomvc/blob/f48302376244513396de3e353e73ba136151b874/src/index.tsx#L54-L58
GitHub
solid-todomvc/src/index.tsx at f48302376244513396de3e353e73ba136151...
Solid implementation of TodoMVC. Contribute to solidjs/solid-todomvc development by creating an account on GitHub.
p2
p2OP4w ago
thanks!

Did you find this page helpful?