Advertisement
haniherbertho

Working with Data - Build a Github Card Component

Jan 31st, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. const Card = (props) => {
  2. return (
  3. <div style={{margin: '1em'}}>
  4. <img width="75" src="https://avatars1.githubusercontent.com/u/8445?v=4" />
  5. <div style={{display: 'inline-block', marginLeft: 10}}>
  6. <div style={{fontSize: '1.25em', fontWeight: 'bold'}}>
  7. Paul O’Shannessy
  8. </div>
  9. <div>Facebook</div>
  10. </div>
  11. </div>
  12. );
  13. };
  14.  
  15. const CardList = (props) => {
  16. return (
  17. <div>
  18. <Card />
  19. </div>
  20. )
  21. }
  22.  
  23. ReactDOM.render(<CardList />, mountNode);
  24.  
  25. ------------------------------------------------------------------------------------------------------------------------------
  26.  
  27. const Card = (props) => {
  28. return (
  29. <div style={{margin: '1em'}}>
  30. <img width="75" src={props.avatar_url} />
  31. <div style={{display: 'inline-block', marginLeft: 10}}>
  32. <div style={{fontSize: '1.25em', fontWeight: 'bold'}}>
  33. {props.name}
  34. </div>
  35. <div>{props.company}</div>
  36. </div>
  37. </div>
  38. );
  39. };
  40.  
  41. const CardList = (props) => {
  42. return (
  43. <div>
  44. <Card name="Paul O’Shannessy"
  45. avatar_url="https://avatars1.githubusercontent.com/u/8445?v=4"
  46. company="Facebook"
  47. />
  48. <Card />
  49. </div>
  50. )
  51. }
  52.  
  53. ReactDOM.render(<CardList />, mountNode);
  54.  
  55. ------------------------------------------------------------------------------------------------------------------------------
  56.  
  57. const Card = (props) => {
  58. return (
  59. <div style={{margin: '1em'}}>
  60. <img width="75" src={props.avatar_url} />
  61. <div style={{display: 'inline-block', marginLeft: 10}}>
  62. <div style={{fontSize: '1.25em', fontWeight: 'bold'}}>
  63. {props.name}
  64. </div>
  65. <div>{props.company}</div>
  66. </div>
  67. </div>
  68. );
  69. };
  70.  
  71. let data = [
  72. { name: "Paul O’Shannessy",
  73. avatar_urlCheck: "https://avatars1.githubusercontent.com/u/8445?v=4",
  74. company: "Facebook" },
  75. { name: "PJ Hyett",
  76. avatar_urlCheck: "https://avatars0.githubusercontent.com/u/3?v=4",
  77. company: "GitHub, Inc." },
  78. ];
  79.  
  80. const CardList = (props) => {
  81. return (
  82. <div>
  83. {props.cards.map(card => <Card name={card.name} company={card.company} avatar_url={card.avatar_urlCheck}/>)}
  84. </div>
  85. )
  86. }
  87.  
  88. ReactDOM.render(<CardList cards={data}/>, mountNode);
  89.  
  90. ------------------------------------------------------------------------------------------------------------------------------
  91.  
  92. const Card = (props) => {
  93. return (
  94. <div style={{margin: '1em'}}>
  95. <img width="75" src={props.avatar_url} />
  96. <div style={{display: 'inline-block', marginLeft: 10}}>
  97. <div style={{fontSize: '1.25em', fontWeight: 'bold'}}>
  98. {props.name}
  99. </div>
  100. <div>{props.company}</div>
  101. </div>
  102. </div>
  103. );
  104. };
  105.  
  106. let data = [
  107. { name: "Paul O’Shannessy",
  108. avatar_url: "https://avatars1.githubusercontent.com/u/8445?v=4",
  109. company: "Facebook" },
  110. { name: "PJ Hyett",
  111. avatar_url: "https://avatars0.githubusercontent.com/u/3?v=4",
  112. company: "GitHub, Inc." },
  113. ];
  114.  
  115. const CardList = (props) => {
  116. return (
  117. <div>
  118. {props.cards.map(card => <Card {...card}/>)}
  119. </div>
  120. )
  121. }
  122.  
  123. ReactDOM.render(<CardList cards={data}/>, mountNode);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement