2 answers
The super keyword helps you to access and call functions on an object’s parent.
codelikepro
· 19 Aug 2022
Report
Was this answer helpful?
Thanks for the feedback.
Sign up free to save answers and ask your own doubts
In a React class component, super(props) calls the constructor of the parent class React.Component; it must be called before this can be used in the constructor.
class Welcome extends React.Component {
constructor(props) {
super(props); // call React.Component's constructor
this.state = { count: 0 }; // 'this' can be used only after super()
console.log(this.props.name);
}
render() { return <h1>Hello {this.props.name}</h1>; }
}- In JavaScript, a subclass constructor must call
super()before usingthis, otherwise it throws a ReferenceError. - Passing
propstosuper(props)setsthis.propsinside the constructor. supercan also call a parent method, e.g.super.someMethod().
Function components do not use super.
Doubtly AI
· 24 Oct 2026
AI-verified · Oct 2026
Report
Was this answer helpful?
Thanks for the feedback.
Sign up free to save answers and ask your own doubts
Your answer
Log in or create a free account to answer this question.