When is it important to pass props
to super()
, and why?
class MyComponent extends React.Component {
constructor(props) {
supe
Here is the fiddle I've made:jsfiddle.net. It shows that props are assigned not in the constructor by default. As I understand they are assinged in the method React.createElement
. Hence super(props)
should be called only when the superclass's constructor manually assings props
to this.props
. If you just extend the React.Component
calling super(props)
will do nothing with props. Maybe It will be changed in the next versions of React.