These methods are called in the following order when an instance of a component is created and inserted into the DOM:
- constructor() ⬅
- render()
- componentDidMount()
- We use it when we want to pass
props
to the class component. - By default it must contain
super
keyword, that receivesprops
as argument fromconstructor
. - If we are setting the
state
inconstructor
we have to usethis
keyword. - We can use it to
bind()
value ofthis
to the methods. - If we are not initializing the
state
fromprops
and we are not binding methods, we don’t need to use/write theconstructor(){ ... }
block in our React component.