Guest User

Untitled

a guest
Jun 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. const homeList = [
  2. {
  3. id: '1',
  4. name: 'a',
  5. address: 'aaaaa',
  6. photo: 'A',
  7. description: 'AAA',
  8. },
  9. {
  10. id: '2',
  11. name: 'b',
  12. address: 'bbbbb',
  13. photo: 'B',
  14. description: 'BBB',
  15. },
  16. {
  17. id: '3',
  18. name: 'c',
  19. address: 'ccccc',
  20. photo: 'C',
  21. description: 'CCC',
  22. },
  23. ];
  24.  
  25. class HomeList extends React.Component {
  26. render() {
  27. return (
  28. <div>
  29. <h3>HomeList</h3>
  30. <HomeListItem items={homeList} />
  31. </div>
  32. );
  33. }
  34. }
  35.  
  36. class HomeListItem extends React.Component {
  37. render() {
  38. return (
  39. <div>
  40. {this.props.items.map((item) => (
  41. <div key={item.id}>
  42. <h3>{item.name}</h3>
  43. <div>Address: {item.address}</div>
  44. <div>Photo: {item.photo}</div>
  45. <div>Description: {item.description}</div>
  46. <div>---------------------</div>
  47. </div>
  48. ))}
  49. </div>
  50. );
  51. }
  52. }
  53.  
  54. ReactDOM.render(
  55. <HomeList />,
  56. document.getElementById('root')
  57. );
Add Comment
Please, Sign In to add comment