Answer the question
In order to leave comments, you need to log in
Why pass props to constructor parameters in React?
I went through the official tutorial on the react and there was no such thing, but in some resources I noticed the following:
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
title: 'Hello'
}
render() {
return (
<div>{this.state.title}</div>
)
}
Answer the question
In order to leave comments, you need to log in
Super allows you to access the constructor method of the parent class. The only reason to include props is to access this.props inside your constructor.
https://stackoverflow.com/questions/30571875/whats...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question