I have a use case, where:
0.This is the image that represents what I'm trying to achieve.
To do that, I'm using onchange events in both html elements as I show:
<IonCheckbox slot="start" color='primary' checked={checked} onIonChange={changeCheckbox} />
<IonInput inputMode="numeric" color='light' value={inputValue} onIonChange={changeInputValue} />
The main problem with this is that when I change the checked value, it triggers the input onChange event and vice versa.
const [checked, setChecked] = useState<boolean>(true);
const [inputValue, setInputValue] = useState<string>(value);
function changeCheckbox(event: any) {
setChecked(event.detail.checked);
setInputValue(event.detail.checked ? value : '0');
}
function changeInputValue(event: any) {
setInputValue(event.target.value);
if (checked) {
setChecked(false);
}
}