I would like to update my object and keep the reactivity. selectedTime
is a Date object, substractMonths
will return a new Date object.
<span
class="calendar__pickable__chevron"
@click="selectedTime = substractMonths(1, selectedTime)"
>
<span>
<font-awesome-icon icon="chevron-left" />
</span>
</span>
The problem is that by doing this, my state is not updated because Vue 3 is not able to detect the replacement of the object.
How I can fix this it ? (I specify that I have used const selectedTime = ref(new Date())
to create a reactive object).
Substract function does return new Date
object.
Part of code: https://gist.github.com/SirMishaa/efb0efe74c6355aabbcb853f7650c22f
The only thing I try to do is to execute a function that returns a new date, and replace my selectedTime
with the return value of the function.