Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const SearchContainer=()=>{
- options = ["Any","Starter","Main Course", "Dessert"]
- return h("div", {}
- , h(SelectorPresentational, {options})
- , h(SearchMenuPresentational)
- );
- }
- const SelectorPresentational=({options})=>{
- const [choice, setChoice]=React.useState("Select an option");
- return h("div", {}
- , h("select", { value:choice, onChange: e=>setChoice(e.target.value) }
- , h("option", {value:""}, "Choose one:")
- , options.map((x ,i)=> // map passes element x and index i
- h("option", {value:i, key:x}, x))
- )
- , (choice?" You chose ":"")
- , choice, " "
- , options[choice]
- );
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement