I am trying to update object's value using setState
In my code I am trying to update Date to 2019-06-22 and also update other values such as {dots: [vacation, massage, workout], selected: true}.
My Code:
this.setState(({pressedDate}) => ({
pressedDate: {
...pressedDate,
Date:'2019-06-22', :
{
dots: [vacation, massage, workout], selected: true
}
},
}))
This will give me an error. I think my code is okay but don't know what is wrong.
Any advise or comments would be really appreciated! Thanks in advance!
Thanks @bkm412 I have the solution:
const newDate = '2019-06-22'
this.setState(({pressedDate}) => ({
pressedDate: {
...pressedDate,
[newDate] :
{
dots: [vacation, massage, workout], selected: true
}
},
}))