Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1.  
  2. const SearchContainer=()=>{
  3. options = ["Any","Starter","Main Course", "Dessert"]
  4.  
  5. return h("div", {}
  6. , h(SelectorPresentational, {options})
  7. , h(SearchMenuPresentational)
  8. );
  9. }
  10.  
  11. const SelectorPresentational=({options})=>{
  12. const [choice, setChoice]=React.useState("Select an option");
  13.  
  14. return h("div", {}
  15. , h("select", { value:choice, onChange: e=>setChoice(e.target.value) }
  16. , h("option", {value:""}, "Choose one:")
  17. , options.map((x ,i)=> // map passes element x and index i
  18. h("option", {value:i, key:x}, x))
  19. )
  20. , (choice?" You chose ":"")
  21. , choice, " "
  22. , options[choice]
  23. );
  24. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement