admin管理员组文章数量:1356784
I'm pretty new to React, so I'm having an issue with the main class I'm trying to setup. I thought that when you setup a constructor that you need to setup super() to be able to use 'this'. However, I get this error: "SyntaxError: super() is only valid in derived class constructors". I am unable to find anyone else having this issue. The class in question is below.
class TheClassName extends React.Component {
contructor(props) {
super(props);
this.state = {stuff: Array(10).fill(null), stufftwo: false, stuffthree: 'Stuff'};
}
}
I'm pretty new to React, so I'm having an issue with the main class I'm trying to setup. I thought that when you setup a constructor that you need to setup super() to be able to use 'this'. However, I get this error: "SyntaxError: super() is only valid in derived class constructors". I am unable to find anyone else having this issue. The class in question is below.
class TheClassName extends React.Component {
contructor(props) {
super(props);
this.state = {stuff: Array(10).fill(null), stufftwo: false, stuffthree: 'Stuff'};
}
}
Share
Improve this question
asked Apr 21, 2019 at 20:33
entropic616entropic616
1011 silver badge9 bronze badges
1 Answer
Reset to default 10You forgot the s
in constructor
. :-)
本文标签: javascriptSyntaxError super() is only valid in derived class constructorsStack Overflow
版权声明:本文标题:javascript - SyntaxError: super() is only valid in derived class constructors - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744047350a2581775.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论