I am trying to set a default value in my select tag so that on every onChange event I can call an API which is my requirement.
I searched online on how to set defaultvalue for select tag, people suggested to use defaultValue attribute which did not work for me.
let serviceProviderLocationNames = this.props.serviceProviderLocationName.map((location, key) => {
return <option key={key} value={location.SERVICE_PROVIDER_LOCATION_ID}>{location.DESCRIPTION}</option>
});
<select
defaultValue = {{ label: "Select", value: 0}}
name="serviceProviderLocationDropDown"
onChange={this.updateServiceProviderLocationId}
>
{serviceProviderLocationNames}
</select>
I expected to see a "select" value as default and others to be the values that I got from an API, but I couldn't see the "select"