Component Constructor and Super Question - How to Use Props Argument


(Frederico De Paoli) #1

It seems like in the constructor(props) function for a React component, you can use props in the constructor without having given super() the props argument. Somehow, React still knows that props is to be assigned to this in the constructor, as in, the component instance. However, if you try to assign this.props in the component constructor explicitly, without super(props), it will give an error. Why is it that it doesn’t let you call this.props but when calling props, it knows you are referring to this.props?