Modal中React原生纸张TextInput,输入一个字符后光标向后闪烁

Rid*_*ler 5 javascript reactjs react-native react-native-paper react-native-modal

React Native 论文中 Modal 上 TextInput 的一些奇怪行为。当我输入一个字符时,它被输入到文本框中,但随后光标闪回(就像被删除一样),然后又重新出现。这一切发生得非常快,并且保留了角色,但这一切看起来有点卡顿。下面的GIF来说明:

在此输入图像描述

对于模式来说,代码相当简单:

import { Portal, Modal, Button, Title, Text, TextInput } from 'react-native-paper'; 

const [nameNew, setNameNew] = useState('')
const [emailNew, setEmailNew] = useState('')

const renderModalAddPerson = () => {
    return (
      <Portal>
        <Modal visible={visibleModalAddPerson} onDismiss={closeModalAddPerson} contentContainerStyle={styles.modalContainer}>
          <View>
            <Title style={{alignSelf:'center'}}>Title here</Title>
            <Text>  </Text>
            <TextInput
              mode="outlined"
              label="Name"
              style={{alignSelf:'center', width:'95%'}}
              value={nameNew}
              onChangeText={nameNew => setNameNew(nameNew)}
              ref={input1}
              returnKeyType='next'
              blurOnSubmit={false}
              onSubmitEditing={() => input2.current.focus()}
            />
            <TextInput
              mode="outlined"
              label="Email"
              style={{alignSelf:'center', width:'95%'}}
              value={emailNew}
              onChangeText={emailNew => setEmailNew(emailNew)}
              ref={input2}
              returnKeyType='done'
              blurOnSubmit={false}
              onSubmitEditing={() => addPerson()}
            />
            <Button
              uppercase={false} 
              style={{backgroundColor:'#2c3e50', width: '95%', alignSelf:'center', margin: 10}} 
              labelStyle={{color:'white'}}
              onPress={()=>addPerson()}
            >Add person</Button>
          </View>
        </Modal>
      </Portal>
    );
  };
Run Code Online (Sandbox Code Playgroud)

在 iOS 上观察到的问题,未在 Android 上测试

Rid*_*ler 11

看起来这是 React Native 中的一个已知错误。我发现的最佳解决方案是使用 defaultValue prop 而不是 value。