最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SyntaxError: super() is only valid in derived class constructors - Stack Overflow

programmeradmin0浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 10

You forgot the s in constructor. :-)

发布评论

评论列表(0)

  1. 暂无评论