constructor() is the First Life Cycle Method.
constructor() is called before anything else, when the component is initiated.
It comes under Mounting phase. It means it DOES NOT gets called when state is updated.
super() method is used inside constructor() before writing anything else. We normally initialize initial state and initial values inside the constructor.
We should NEVER call API inside the constructor() because it is called before anything else & HTML may not be ready.
Comments
Post a Comment