In this part we are going to talking about the life cycle which is updating.
So it is the middle one the first step is to get revived Dave.
Pop that we already explained that in the previous Natura so we can add this function to here and the
next part is the should component update first component update is to let we know that if a component
output is not affected by the current change in state or pulse of course the default behavior is to
get into of course the default behavior is to render on ever each day change this method is invoked
before rendering brand new pops or state of being received by the default value should be true.
This method is rarely used it only exists as a performance optimization and so do not rely on event
rendering.
And this may cause a box.
Now we are going to add this effort and we said that default value to be true first and then we go to
this random method and which we already explained it in the previous that year or two.
So now we can go to the next step is to get snapshot before update these scare naps all beef up day
e a new life cycle method introduced in we add any value we'd heard by this life cycle will be past
it as a perfect of two components update.
And this is not very common.
This method is used to handle some cases such as the scope position in a special way.
Now we are going to add this method and we are going to return some snapshot here and to see whether
it will also dissipate it into a component to update method.
So the last thing is the component did update that we are set this life cycle method.
It looked at as soon as the updating happens.
The most common use case for the component the day is to update it bomb it responds to the Pops or state
change.
This is also a good place to do some extra GP we class as long as you compare with the current pops
to the previous Pops.
You can also fast stay here but remember to check the water state or pop change for the previous state
the incorrect use offsets they can lead to an infinite loop.
So now we add the component to update and we are also casting red.
We will this paint a snapshot.
This is the snapshot that we expect to dissipate it in the component update.
Now we are going to try to build a great web so MTM everyone's build.
Now as you can see this is the production build and you can see this is the original creation lifecycle
which is the constructor for us and then the get derived date of J S and then you start rendering the
empty.
And by rendering the free cost.
And it will and we have the G S competently Mond and as you can see there is no component to update
here because we haven't update any changes in the color.
So let's try to type some word to make some changes maybe with type 1 and then you can see that it should
come with an update here and there is only one card change so days only one should component update
displayed here.
And as you can see the steps are already passed to the component it update and there is last thing that
we haven't tried is to change this to force.
Now we try to be able to get in now after we refresh the page and we try to update because we already
set a should component update is false.
So you can see even we type this can be updated.
So this is how the should component update work.
And also how do we add lifecycle of updating.