You have not imported Component from react.So yo must have to import Component from 'react' .so your code will be looks like(您尚未从react导入Component,所以您必须从'react'导入Component,这样您的代码将看起来像)
import React,{Component} from 'react';
import {hot} from "react-hot-loader";
import Heroes from "./components/Heroes"
class App extends Component {
render() {
return (
<Heroes heroes={this.state.heroes} />
)
}
state = {
heroes: []
};
componentDidMount() {
fetch('https://api.opendota.com/api/heroes')
.then(res => res.json())
.then((data) => {
this.setState({ heroes: data })
})
.catch(console.log)
}
}
export default hot(module)(App);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…