React this.props is undefined

I think you’re missing the following, try replacing your constructor:

constructor(props) {
    super(props);

    console.log(this.props)
}

Try it out, you should get output from this.props.

The constructor for a React component is called before it is mounted.
When implementing the constructor for a React.Component subclass, you
should call super(props) before any other statement. Otherwise,
this.props will be undefined in the constructor, which can lead to
bugs. Source: ReactJS.org Component Docs.

Leave a Comment