How to properly type refs to ionic inputs?

See the screenshot error plz


Clearly, const inputRef = useRef<HTMLIonInputElement>(); is not enough.

The ref should be cast as follows:
const inputRef = useRef() as RefObject<HTMLIonInputElement>;

Try updating your ref to:
const inputRef = useRef<HTMLIonInputElement>(null);
with the null as the default value, as elements can either be defined or null, but not undefined.

1 Like

Far from intuitive, but thanks!