'Calling parent constructor with props for react states

    class Example extends React.Component {
      constructor(props) {
        super(props);
        this.state = {count: 0};
      }
     ....
   }

In the code above:

Why do we have to call both the constructor and super with props to use the state property ? Because i may not use this.props in the constructor of the inherited component. Just the state initialization.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source