2

I have an otp input field and I want it to be autofocused on initial rendering(using hooks, smart and dumb component) The field is inside an IonModal

import OtpInput from "react-otp-input"; 
import {IonInput, IonModal} from '@ionic/react';

<IonModal isOpen={true} cssClass={classes.someClass} showBackdrop={false} >
  <OtpInput
    shouldAutoFocus={true}
    value={props.otp}
    numInputs={6}
  />
</IonModal>

I want specifically OtpInput but I also tried with IonInput, it's also not autofocusable

<IonInput
    autofocus={true}
    type="number"
    label="Enter OTP"
/>

tried autofocus attribute, document.querySelecterAll, couldnt try document.getElementById cause somehow Id is not showing on the element

What I am missing?

Learner
  • 41
  • 2
  • 8

1 Answers1

-1

This should work.

<ion-input autofocus="true"></ion-input>
Muhammad Ayyaz
  • 11
  • 1
  • 14