0
What is the scope of the method super() in react.js
3 Respostas
+ 6
super keyword is not a React specific method but ES6+ keyword.
It's recommended to have a good understanding of modern JavaScript features (ES6+) before leaping into React.
We need super keyword when inheritance is present. See this(entire lesson):
https://www.sololearn.com/learn/JavaScript/2979/
"The super keyword is used to access and call functions on an object's parent.
...
When used in a constructor, the super keyword appears alone and must be used before the this keyword is used. The super keyword can also be used to call functions on a parent object."
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super
So, yes, when extending React.Component you should call super() in the constructor before using "this" keyword.
0
React.component
0
I didn't mean react scope. I ment its porpoise . What is it used for