当我使用如下所示的标记时,出现此错误!
反应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;
答案 0 :(得分:2)
看起来应该有class Fullpage extends Component
而不是Comment
。