Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. /*
  2. 1. Import todos data from a JSON file
  3. 2. Load it into the component's state
  4. 3. map over the state object to display the todo items
  5. */
  6.  
  7. import React from "react";
  8. import TodoItem from "./TodoItem";
  9. import todosData from "./todosData";
  10.  
  11. class App extends React.Component {
  12. constructor() {
  13. super();
  14. this.state = {
  15. todos: todosData
  16. };
  17. }
  18.  
  19. render() {
  20. const todoItems = this.state.todos.map(item => (
  21. <TodoItem key={item.id} item={item} />
  22. ));
  23.  
  24. return <div className="todo-list">{todoItems}</div>;
  25. }
  26. }
  27.  
  28. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement