I apologize for the noob question but this is my way of understanding a framework each time I learn a new one. From what little I know about React at the moment is I understand that we pass props to the constructor and super calls when the component making the call is going to receive props.
But what I don't understand is the many Youtube tutorials I have watched still pass props to the constructor and super calls even if the component is the 'parent-most' component or doesn't even receive any props altogether, let alone make use of it. Why do they do this?
I have to look up why there are constructors at all but regarding state/props you can handle it the following way:
you can leave out the constructor at all except you want to initialize your (component)-state with values from the incoming props or some initializiation where componentDidMount is to late for. you still will receive props with a missing constructor. just try it out like on codesandbox.
Rafael Rozon
Developer
If you're extending some class you need to make sure the parent class is properly initialized before your class. This is OOP, not just React/JS. A few things to keep in mind: