Raman Choudhary
Raman Choudhary

Reputation: 4403

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

I'm creating a Component that has multiple <select> 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 onSelect that I can use to achieve this or, any better method?

Upvotes: 0

Views: 2197

Answers (1)

Pineda
Pineda

Reputation: 7593

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.

Upvotes: 1

Related Questions