So how should we update the state instead.
Well we can use our spread operator here and spread all our existing to do is into disarray and then
just add the new to do as a new item at the end.
This works but it's not the cleanest way of updating this.
It will most likely work in all scenarios we have in this app but theoretically react schedules state
updates and data for what's it are to do is value here might not necessarily be the latest state when
this update is performed to guarantee this we can pass a function to the state updating function or
though a function which gets our previous to do this and which then returns to new state.
This also is supported by react dysfunction will all be called by react for us and then we can rely
on prefer to do is inside of this function to really be the latest state snapshot.
Now with that we update our to do with with the Ulta dos and the new one and now we have a function
near where we should be able to add new to do this.
So if we now save all of that and we go back to the application and enter finish the course here does
works.
And if I enter finish it in one month here this is also added.
So this not all works the missing functionality now is that we can also delete them.
We'll do this in the next lecture but more importantly than that you now also learn how to manage state
with react and typescript which besides props of course is a number a core concept.