S
SolidJS4mo ago
abe

Confused between For and index

Could someone please explain this a little more in depth, I am not able to follow the explanation on the tutorial.
No description
5 Replies
Eve
Eve4mo ago
In simplest terms, with For the value is reactive. With Index the index is reactive. So if you want to redraw when a value changes, use for. If you want to redraw when an item in the array is added/removed, use index
weeBlord
weeBlord4mo ago
What if both need to be reactive? :solid:
Đăng Tú
Đăng Tú4mo ago
Maybe nesting those components?
bigmistqke
bigmistqke4mo ago
There is https://primitives.solidjs.community/package/list where both index and the element are a signal
Solid Primitives
A library of high-quality primitives that extend SolidJS reactivity
bigmistqke
bigmistqke4mo ago
But there are little use cases for it. It came in handy one time where I received immutable data from another library and I didn't know about reconciled merge option.

Did you find this page helpful?