I created a React app with Ionic 5 and I want to set the default value of a select element that is shown in a form.
This SO question is all about Angular, but I need to do this in React.
Here's my select code:
<IonSelect id="category" name="group" ref={register}>
<IonSelectOption key="noGroup" value="noGroup">No group</IonSelectOption>
<IonSelectOption key="addTerm" value="addTerm">Add a group</IonSelectOption>
{
termList.map((item) => (
<IonSelectOption key={item.id} value={item.id}>{item.name}</IonSelectOption>
))
}
</IonSelect>
I want to set the default value of this select to noGroup
when the page is loaded. How can I do that?
The ion-select documentation does not have any information on this.