Created
May 5, 2019 09:51
-
-
Save sbeugen/1838cf4d31a4e416a0f27efa769b2c43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import useErrorPopover from "./use-error-popover"; | |
| const CustomSelectWithHook = ({ value, name, placeholder, onChange, options, errorMessage }) => { | |
| const elementRef = useErrorPopover(errorMessage); | |
| return ( | |
| <select | |
| style={{ borderBottom: `1px solid ${errorMessage ? "red" : "blue"}` }} | |
| name={name} | |
| value={value} | |
| onChange={onChange} | |
| ref={elementRef} | |
| > | |
| <option value="" label={placeholder} disabled defaultValue hidden /> | |
| {options.map((option, index) => ( | |
| <option value={option.value} label={option.label} key={index} /> | |
| ))} | |
| </select> | |
| ); | |
| }; | |
| export default CustomSelectWithHook; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment