我是 ReactJS 的新手,我想从 Traversy Media 的视频教程中学习基础知识,我将代码应用到他必须做的事情上。但我被困在这部分,因为我得到一个错误,无法编译,如下所示:
这是我写的代码:
应用程序.js
import React, { Component } from 'react';
import Todos from './components/Todos';
import './App.css';
class App extends Component {
state = {
todos: [
{
id: 1,
title: 'Take out he trash',
completed: false
},
{
id: 2,
title: 'Have a Dinner',
completed: false
},
{
id: 3,
title: 'Meeting with Boss',
completed: false
},
]
};
render() {
return (
<div className="App">
<Todos todos={this.state.todos} />
</div>
);
}
}
export default App;
Todos.js
import React, {Component} from 'react';
import TodoItem from './TodoItem';
class Todos extends Component {
render() {
return this.props.todos.map((todo) => (
<TodoItem/>
));
}
}
export default Todos;
TodoItem.js
import React, { Component } from 'react';
export class TodoItem extends Component{
render(){
return{
<div>
<p>Hello</p>
</div>
}
}
}
export default TodoItem;