Raman Choudhary Raman Choudhary - 1 year ago 86
HTML Question

Alternative for onChange event for <select> tag in ReactJS?

I'm creating a Component that has multiple

tags. Based on the selected option it fetches options for the next tag. I'm using onChange event. The problem I'm facing is if there's only 1 option in then onChange is never triggered.

Is there any event in ReactJS, like
that I can use to achieve this or, any better method?

Answer Source

Could you not make the first option a disabled placeholder as follows:

<option disabled selected value> -- select an option -- </option>

That way the the user would have to trigger a fetch.

If you require a default state you can handle this outside of the select box.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download