作为一个初学者,我正在尝试将默认的响应登陆页面从header.js渲染为index.js。 请帮我解释我哪里错了 Index.js-
import React from 'react';
import ReactDOM from 'react-dom';
import './header.css';
import Header from './header';
import registerServiceWorker from './registerServiceWorker';
class App extends Component {
render() {
return (
<Header />
);
}
}
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
header.js-
import React from 'react';
import ReactDOM from 'react-dom';
import './header.css';
import registerServiceWorker from './registerServiceWorker';
class Header extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}
错误-
./src/index.js
Line 7: 'Component' is not defined no-undef