我的文本输入在焦点后直接反应本机模糊

My textinput in react native blurs directly after focus

我在 react-native 中有两种形式。其中一个工作完美,另一个(在另一个组件中)有一个错误。获取焦点时,表单中的 TextInputs 会一直模糊。

我制作的视频(见下面的 gif)显示,每当我点击输入时,它都会获得焦点,然后立即模糊。

输入代码(现在有调试):

<TextInput value={group.name}
    blurOnSubmit={false}
    onBlur={() => console.log('I blur')}
    onFocus={() => console.log('I focus')}
    autoFocus={true} style={styles.textInput} />

我找到了答案...我很困惑为什么这是答案,但我们开始吧:

显然,当您在 TabBarIOS 组件内呈现 TextInput 并在选项卡上设置 selected={true} 时,将无法在 TextInputs 中输入内容。我不知道为什么。我在 true 上有这个,以便在构建视图时不必每次都单击选项卡。我想我会设置不同的默认值:)

**安装

  1. 安装 React Navigation

    npm 安装反应导航

  2. 安装依赖项

    expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view

  3. 安装 React Navigation Stack

    npm 安装 react-navigation-stack @react-native-community/masked-view

我刚遇到同样的问题。在我的例子中,问题是我的 TextInput 是 <TouchableWithoutFeedback onPress={Keyboard.dismiss}> 的 child。一起删除此组件解决了这个问题。