'Custom dropdown in react - on change
I have build this
https://andela.com/insights/react-js-tutorial-on-creating-a-custom-select-dropdown/
It uses a Ul and li to have a nicely styled dropdown. However I want to detect the change on the component.
<Dropdown onChange={doSomething} options ={['Option1', 'Option2', 'Option3']}/>
Currently I have a hidden select which triggers the change
<select onChange={onChange}>
{options.map(option => (
<option key="index">
{option}
</option>
))}
</select>
Was wondering if there was a better way, coming from vue you can use $emit to emit an event up to the parent. Is there a similar mechanism is React or is there a better way than a hidden select?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
