Поставьте зависимости:
npm install react-native-reanimatedpnpm add react-native-reanimatedyarn add react-native-reanimatedbun add react-native-reanimatedСкопируйте эти файлы в src/shared/components/base/otp-input/:
Код доступен по подпискеPro
Исходник «Ввод OTP» открывается с подпиской Pro. Уже оформили? Войдите в аккаунт.
Проверьте алиас путей. Импорты в коде выше записаны так, как их пишет astra-rn add: @/shared/components, @/shared/utils и @/shared/hooks. Нужен алиас "@/*": ["./src/*"] в tsconfig.json — или поправьте импорты под свои пути.
Код доступен по подпискеPro
Исходник «Ввод OTP» открывается с подпиской Pro. Уже оформили? Войдите в аккаунт.
otpCount?Тип number
containerStyle?Тип StyleProp<ViewStyle>
otpInputStyle?Тип StyleProp<TextStyle>
textStyle?Тип StyleProp<TextStyle>
focusedColor?Тип string
inputWidth?Тип number
inputHeight?Тип number
inputBorderRadius?Тип number
enableAutoFocus?Тип boolean
editable?Тип boolean
onInputFinished?Тип (code: string) => void
onInputChange?Тип (codes: string) => void
enteringAnimated?Тип typeof LinearTransition
exitingAnimated?Тип typeof LinearTransition
error?Тип boolean
errorMessage?Тип string
animationVariant?Тип AnimationVariant
focusedBackgroundColor?Тип string
unfocusedBackgroundColor?Тип string
focusedBorderColor?Тип string
unfocusedBorderColor?Тип string
errorBackgroundColor?Тип string
errorBorderColor?Тип string
ref?Тип React.Ref<IOtpInputRef>
Необязательный ref (IOtpInputRef) позволяет задать код из кода: setValue(code) заполняет поля с той же анимацией цифр и переносит фокус, clear() очищает поля. Без ref поведение не меняется.