We end life cycle has three categories mounting updating and a mounting mounting use the birth of the
Capone would end.
An update is the growth of the component and a month is the death of the component.
And in this part we are going to talk about more in this mounting category.
And first we are going to talk about constructor in the constructor.
We add the console bought lot Ajay as constructor
in the constructor you should not call the SAP state instead.
If your component needs to use local state aside the initial state to state directly in this constructor
and the constructor is the only place that you can assign this state by recipe.
And in other method you should use the distance since they do not do any side effects or subscriptions
in the constructor.
If you really really to do this you have to use the component deep month instead and in the next part.
We are going to talk about that derive state from parks.
So under here we create a new method
in order to get something pop out here.
We have to go with the index start they ask and let's create a title and just set up title to get derived
day from Pops.
Only one proposal and this is not a very come on we get lifecycle method.
It enabled the component to update is internal state as the result of changes in pops.
It usually used in something like scroll direction based on the changing offset prompts so it is where
we use this method and in the next method is the random method.
So we go to the random method and we consult the law.
We require that you have to make the random method pure because then pure member functions pure functions.
Those do not have any side effects by making you some X TTP request and always have the same output
wherein the same input are passed that mean you cannot use that stayed within this method.
And at last we are going to talk about the compute on demand and so we added here
the component each among is invoked immediately after a component is mangled.
If you leave to load data from a remote end point this is a very good place to make some extra GP request.
This method is good to set up any subscription but if you do that don't forget to unsubscribe with the
component amount method that we will talk about later.
And also we go to the county s and we also want to see the court rendering
now as you can see the AB J as constructor one first and then you will get they get the arrived day
from pops and then the app J s start to render and a card also render three times and at last we'll
call the app s component deep mod method.
You will see something very weird because it seems all one double.
For example it should be a one only one time and but it run twice and it should be three times because
we only have free cost.
You should speak cause in the region Rosen rendering use strict mode when one thing in development.
So a strict method intentionally taboo calls to construct and random efforts to better departed and
unexpected side effect.
So if you want to make a real one.
We have to use a dozen built of.
We ate.
So how can we do that and actually please be aware that there is a we at the irrelevant twos.
So every time you see the car is great.
This is in this I guess is in the development build.
So this is not a part of some build.
If we really want to create a product and build we have to run NPM one field and then the production
build of the we add can be found in here.
Now you will see the color of this icon become blue rather than before is red.
So let's take a look on the console.
Now you can see the constructor only one only one time and other also only one one time only the cat
has three times because there is free cast so you can see it.
Also follow the order of the constructor get derived from pops and then we go to the render render free
cost and then at last is the component it Monk.
So this is a mounting life cycles of.
We add.