React, why use super(props) inside of ES6 class constructor? [duplicate]
This question already has an answer here:
What's the difference between “super()” and “super(props)” in React when using es6 classes?
10 answers
I realize the super keyword can be used to call functions in a parent component. However, I'm not totally clear why you would use the super keyword in the example below - just passing it whatever props are being passed to the constructor.
Can someone please shed some light on the various reasons for using the super keyword in an ES6 class constructor, in react?
constructor(props) {
super(props);
this.state = {
course: Object.assign({}, this.props.course),
errors: { }
};
this.updateCourseState = this.updateCourseState.bind(this);
}
reactjs ecmascript-6 super
marked as duplicate by Bergi
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jun 17 '16 at 22:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
What's the difference between “super()” and “super(props)” in React when using es6 classes?
10 answers
I realize the super keyword can be used to call functions in a parent component. However, I'm not totally clear why you would use the super keyword in the example below - just passing it whatever props are being passed to the constructor.
Can someone please shed some light on the various reasons for using the super keyword in an ES6 class constructor, in react?
constructor(props) {
super(props);
this.state = {
course: Object.assign({}, this.props.course),
errors: { }
};
this.updateCourseState = this.updateCourseState.bind(this);
}
reactjs ecmascript-6 super
marked as duplicate by Bergi
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jun 17 '16 at 22:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
It would be helpful to see the class declaration. e.g.class SpecialDialog extends Dialog {
– Conspicuous Compiler
Jun 17 '16 at 22:29
add a comment |
This question already has an answer here:
What's the difference between “super()” and “super(props)” in React when using es6 classes?
10 answers
I realize the super keyword can be used to call functions in a parent component. However, I'm not totally clear why you would use the super keyword in the example below - just passing it whatever props are being passed to the constructor.
Can someone please shed some light on the various reasons for using the super keyword in an ES6 class constructor, in react?
constructor(props) {
super(props);
this.state = {
course: Object.assign({}, this.props.course),
errors: { }
};
this.updateCourseState = this.updateCourseState.bind(this);
}
reactjs ecmascript-6 super
This question already has an answer here:
What's the difference between “super()” and “super(props)” in React when using es6 classes?
10 answers
I realize the super keyword can be used to call functions in a parent component. However, I'm not totally clear why you would use the super keyword in the example below - just passing it whatever props are being passed to the constructor.
Can someone please shed some light on the various reasons for using the super keyword in an ES6 class constructor, in react?
constructor(props) {
super(props);
this.state = {
course: Object.assign({}, this.props.course),
errors: { }
};
this.updateCourseState = this.updateCourseState.bind(this);
}
This question already has an answer here:
What's the difference between “super()” and “super(props)” in React when using es6 classes?
10 answers
reactjs ecmascript-6 super
reactjs ecmascript-6 super
asked Jun 17 '16 at 22:26
malexandersmalexanders
9472935
9472935
marked as duplicate by Bergi
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jun 17 '16 at 22:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Bergi
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jun 17 '16 at 22:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
It would be helpful to see the class declaration. e.g.class SpecialDialog extends Dialog {
– Conspicuous Compiler
Jun 17 '16 at 22:29
add a comment |
It would be helpful to see the class declaration. e.g.class SpecialDialog extends Dialog {
– Conspicuous Compiler
Jun 17 '16 at 22:29
It would be helpful to see the class declaration. e.g.
class SpecialDialog extends Dialog {
– Conspicuous Compiler
Jun 17 '16 at 22:29
It would be helpful to see the class declaration. e.g.
class SpecialDialog extends Dialog {
– Conspicuous Compiler
Jun 17 '16 at 22:29
add a comment |
1 Answer
1
active
oldest
votes
super allows you to access the constructor method of the parent class. The only reason to include props is to access this.props inside of your constructor.
What's the difference between "super()" and "super(props)" in React when using es6 classes?
Great thanks. that answers my question.
– malexanders
Jun 17 '16 at 22:36
2
Can someone expand on this a bit? SoReact.Component
has its own constructor method, and we usesuper()
to trigger that?
– corysimmons
Dec 6 '17 at 20:08
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
super allows you to access the constructor method of the parent class. The only reason to include props is to access this.props inside of your constructor.
What's the difference between "super()" and "super(props)" in React when using es6 classes?
Great thanks. that answers my question.
– malexanders
Jun 17 '16 at 22:36
2
Can someone expand on this a bit? SoReact.Component
has its own constructor method, and we usesuper()
to trigger that?
– corysimmons
Dec 6 '17 at 20:08
add a comment |
super allows you to access the constructor method of the parent class. The only reason to include props is to access this.props inside of your constructor.
What's the difference between "super()" and "super(props)" in React when using es6 classes?
Great thanks. that answers my question.
– malexanders
Jun 17 '16 at 22:36
2
Can someone expand on this a bit? SoReact.Component
has its own constructor method, and we usesuper()
to trigger that?
– corysimmons
Dec 6 '17 at 20:08
add a comment |
super allows you to access the constructor method of the parent class. The only reason to include props is to access this.props inside of your constructor.
What's the difference between "super()" and "super(props)" in React when using es6 classes?
super allows you to access the constructor method of the parent class. The only reason to include props is to access this.props inside of your constructor.
What's the difference between "super()" and "super(props)" in React when using es6 classes?
edited May 23 '17 at 12:34
Community♦
11
11
answered Jun 17 '16 at 22:30
jmancherjejmancherje
3,33631944
3,33631944
Great thanks. that answers my question.
– malexanders
Jun 17 '16 at 22:36
2
Can someone expand on this a bit? SoReact.Component
has its own constructor method, and we usesuper()
to trigger that?
– corysimmons
Dec 6 '17 at 20:08
add a comment |
Great thanks. that answers my question.
– malexanders
Jun 17 '16 at 22:36
2
Can someone expand on this a bit? SoReact.Component
has its own constructor method, and we usesuper()
to trigger that?
– corysimmons
Dec 6 '17 at 20:08
Great thanks. that answers my question.
– malexanders
Jun 17 '16 at 22:36
Great thanks. that answers my question.
– malexanders
Jun 17 '16 at 22:36
2
2
Can someone expand on this a bit? So
React.Component
has its own constructor method, and we use super()
to trigger that?– corysimmons
Dec 6 '17 at 20:08
Can someone expand on this a bit? So
React.Component
has its own constructor method, and we use super()
to trigger that?– corysimmons
Dec 6 '17 at 20:08
add a comment |
It would be helpful to see the class declaration. e.g.
class SpecialDialog extends Dialog {
– Conspicuous Compiler
Jun 17 '16 at 22:29