Advertisement
roberto32

Untitled

Jun 15th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { PropTypes } from 'react'
  2. import Todo from './Todo'
  3.  
  4. const TodoList = ({ todos, onTodoClick, onSelect }) => (
  5.   <ul>
  6.     {todos.map(todo =>
  7.       <Todo
  8.         key={todo.id}
  9.         {...todo}  {/*children, completed, onClick, text */}
  10.         onClick={() => onTodoClick(todo.id)}
  11.       >
  12.         <input type="checkbox" onClick={() => onSelect(todo.id)} />
  13.       </Todo>
  14.     )}
  15.   </ul>
  16. ) // theoretically I could put that checkbox outside <Todo> and put it same .map !!!
  17.  
  18. TodoList.propTypes = {
  19.   todos: PropTypes.arrayOf(PropTypes.shape({
  20.     id: PropTypes.number.isRequired,
  21.     completed: PropTypes.bool.isRequired,
  22.     text: PropTypes.string.isRequired
  23.   }).isRequired).isRequired,
  24.   onTodoClick: PropTypes.func.isRequired
  25. }
  26. console.log(TodoList);
  27. export default TodoList
  28.  
  29. now the folder structure: components$ ls
  30. App.js  Footer.js  Link.js  Todo.js  TodoList.js
  31.  
  32. drwxrwxr-x   2 roberto roberto  4096 máj 15 12:14 actions
  33. drwxrwxr-x   2 roberto roberto  4096 jún 15 13:58 components
  34. drwxrwxr-x   2 roberto roberto  4096 jún 15 13:44 containers
  35. .....
  36.  
  37. and I import it as
  38. import TodoList from '../components/TodoList'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement