Guest User

Untitled

a guest
Aug 21st, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. function LineItem(props) {
  2. return (
  3. <tr>
  4. <td>{props.year}</td>
  5. <td>{props.Model}</td>
  6. <td>{props.Price}</td>
  7. <td><button>Buy Now</button></td>
  8. </tr>
  9. );
  10. }
  11.  
  12. function Header() {
  13. return <tr><th>Year</th><th>Model</th><th>Price</th><th>Buy</th></tr>;
  14. }
  15.  
  16. function Item(props) {
  17. var namesList = props.rows.map(function(row) {
  18. return (
  19. <table>
  20. <Header /><LineItem year={row[0]} Model={row[1]} Price={row[2]} />
  21. </table>
  22. );
  23. });
  24.  
  25. return (
  26. <div>
  27. <h2>{props.title}</h2>
  28. <ul>
  29. {namesList}
  30. </ul>
  31. </div>
  32. );
  33. }
  34.  
  35. function Option(props) {
  36. return <option value={props.value}>{props.value}</option>;
  37. }
  38.  
  39. function Types() {
  40. return (
  41. <select>
  42. <Option value="All" />
  43. <Option value="Cars" />
  44. <Option value="Trucks" />
  45. <Option value="Convertibles" />
  46. </select>
  47. );
  48. }
  49.  
  50. ReactDOM.render(
  51. <div>
  52. <h2>Welcome to React Transportation</h2>
  53. <p>The best place to buy vehicles online</p>
  54. <h2>Choose Options</h2>
  55. <div>
  56. New Only
  57. <input
  58. type="checkbox"
  59. id="coding"
  60. name="interest"
  61. value="coding"
  62. checked
  63. />
  64. </div>
  65. <div>
  66. <Types />
  67. </div>
  68.  
  69. <Item
  70. title="Cars"
  71. rows={[
  72. ["2013", "A", "$32000"],
  73. ["2011", "B", "$4400"],
  74. ["2016", "B", "$15500"]
  75. ]}
  76. />
  77. <Item
  78. title="Trucks"
  79. rows={[["2014", "D", "$18000"], ["2013", "E", "$5200"]]}
  80. />
  81. <Item
  82. title="Convertibles"
  83. rows={[
  84. ["2009", "F", "$2000"],
  85. ["2010", "G", "$6000"],
  86. ["2012", "H", "$12500"],
  87. ["2017", "M", "50000"]
  88. ]}
  89. />
  90. </div>,
  91. document.getElementById("root")
  92. );
Advertisement
Add Comment
Please, Sign In to add comment