反应TypeError:没有'new'不能调用类构造函数全页

时间:2020-07-12 15:16:17

标签: reactjs react-redux

当我使用如下所示的标记时,出现此错误!

反应TypeError:如果没有'new',则无法调用类构造函数全页

在1438行中似乎出了点问题: renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:14803 这是我的Fullpage.js文件:

 import React, {Component} from 'react';
    import './Fullpage.css'
    
    class Fullpage extends Comment{
        render(){
            const {children}=this.props
            return(
                <div className={`fullpage ${this.props.className || ''}`}>
                    {children}
                </div>
            );
        }
        
    }
    
    export default Fullpage

App.js文件:

import React, { Component } from 'react'
import data from './data.json';
import logo from './logo.svg';
import './App.css';
import { SocialIcon } from 'react-social-icons';
import Fullpage from './components/Fullpage.js'

class App extends Component{
    render(){
        return(
          <div className="App container">
              <div className="navigation">
              </div>
              <Fullpage className="first">
                  <h1 className="title" id={"title"}>
                      {data.title}
                  </h1>
                  <div>
                      <h2>
                        {data.subtitle}
                      </h2>
                  </div>

                  <div className="icons-wrapper">
                      {
                          Object.keys(data.links).map(key=>{
                              return(
                                  <div className="icon">
                                  <SocialIcon url={data.links[key]}/>
                                  </div>
                              );
                          })
                      }
                  </div>
              </Fullpage>
              <div className="fullpage">
                  <h3>
                      {data.sections[0].title}
                  </h3>
                  <p>
                      {data.sections[0].items[0].content}
                  </p>
              </div>
              <div className="fullpage">
              </div>
          </div>
        );
    }
}
export default App;

1 个答案:

答案 0 :(得分:2)

看起来应该有class Fullpage extends Component而不是Comment