You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用@twotalltotems/react-native-otp-input遇'getString'为null错误求助

使用@twotalltotems/react-native-otp-input时遇到"cannot read property 'getString' of null"错误

错误截图:
错误截图

我使用@twotalltotems/react-native-otp-input库实现OTP输入功能,完全按照库的README文档中的示例代码编写,但仍出现"cannot read property 'getString' of null"错误。

我的代码如下:

import OTPInputView from '@twotalltotems/react-native-otp-input'
import React from "react";
import {StyleSheet, View, TouchableOpacity, Dimensions, KeyboardAvoidingView, Text} from "react-native";

const screenHeight = Dimensions.get('window').height
export default OtpScreenComponent = () => {

  return (
    <KeyboardAvoidingView>
      <View style={styles.container}>
        <OTPInputView
          style={{width: '80%', height: 200}}
          pinCount={6}
          autoFocusOnLoad
          codeInputFieldStyle={styles.underlineStyleBase}
          codeInputHighlightStyle={styles.underlineStyleHighLighted}
          onCodeFilled={(code => {
            console.log(`Code is ${code}, you are good to go!`)
          })}
        />
        <TouchableOpacity onPress={() => {}}> 
          <Text>Submit Code</Text>
        </TouchableOpacity>
      </View>
    </KeyboardAvoidingView>
  );
}

请问是否需要额外配置(如修改build.gradle文件)才能正常使用该库,恳请帮忙解答,谢谢。

内容的提问来源于stack exchange,提问作者Anjali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 07:32:47