I have multiple inputs, each in it's own IonItem. I'm using onIonChange to set the value of the input to the value typed by the user. But when I click in one input other inputs activate, as if the onIonChange is triggering them. Below is a sample of my component:
const ReservationForm: React.FC = () => {
const [name, setName] = useState<string>();
const [email, setEmail] = useState<string>();
const [phone, setPhone] = useState<number>();
return (
<IonList>
<IonItemDivider className="backgroundPrimary">Guest</IonItemDivider>
<IonItem>
<IonLabel position="stacked">Name</IonLabel>
<IonInput value={name} onIonChange={e => setName(e.detail.value!)}></IonInput>
</IonItem>
<IonItem>
<IonLabel position="stacked">Email</IonLabel>
<IonInput value={email} onIonChange={e => setEmail(e.detail.value!)}></IonInput>
</IonItem>
<IonItem>
<IonLabel position="stacked">Phone Number</IonLabel>
<IonInput type="number" value={phone} onIonChange={e => setPhone(parseInt(e.detail.value!, 10))}></IonInput>
</IonItem>
</IonList>
);
};
export default ReservationForm;
Here is an image of the problem:
as you can see I typed a letter in email but the floating label on phone number was trigger as well. Am I doing something wrong with useState or is this something wrong with the binding? Any help appreciated.
I'm using Ionic 5 with React
