SHARE
TWEET

Untitled

a guest Aug 25th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top