How to update date object?
I have the following situation: I have an array of date object and I need to update the date by knowing its index.
So I tried this approach and it doesn't work.
------------------------------------------------------
So how can I do that via "mutation" approach? (I don't need immutable way) Whould I use
createMutable
or createStore
for that?4 Replies
with a signal you need to update both the array and the date immutably, with a store you'd just need to update the date immutably (as dates aren't tracked by stores)
if you do want to use a store then use
createStore
I got it, but still ther it no point in create new date object. Just want to update object an rerender that.
"ther it no point in create new date object" for me.
you need to create a new Date as solid doesn't track the value inside of a Date to know if it changed, it only tracks the object reference
as a more general rule Solid doesn't track inside classes except for some circumstances, only plain arrays and objects
Use createTrigger from
@solid-primitives/trigger
to create a single reactive trigger, then use dirty() whenever you update the Date object using its methods and track() in the functions/memos you use to read from its methods.