In React - How props are defined initially?

26 views Asked by At

Suppose a component -

class MyComponent extends React.Component {
   render() {
    return <h1>Hi, {this.props.name}</h1>
  }
}

And the instance of MyComponent -

class Parent extends React.Component {
  render() {
    return <MyComponent name = 'Jack' />
  }
}

How can we even define props without defining it in the constructor of MyComponent like -

constructor(props) {
  super(props);
}
0

There are 0 answers