App.jsx 576 B

12345678910111213141516171819202122232425262728293031
  1. // App component : represents the whole app.
  2. App = React.createClass({
  3. getTasks() {
  4. return [
  5. { _id: 1, text: "This is task 1" },
  6. { _id: 2, text: "This is task 2" },
  7. { _id: 3, text: "This is task 3" }
  8. ];
  9. },
  10. renderTasks() {
  11. return this.getTasks().map((task) => {
  12. return <Task key={task._id} task={task} />;
  13. });
  14. },
  15. render() {
  16. return (
  17. <div className="container">
  18. <header>
  19. <h1>Todo list</h1>
  20. </header>
  21. <ul>
  22. {this.renderTasks()}
  23. </ul>
  24. </div>
  25. );
  26. }
  27. });