Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 键盘不';t出现在每个焦点上_Reactjs_React Native_Autofocus_React Native Paper - Fatal编程技术网

Reactjs 键盘不';t出现在每个焦点上

Reactjs 键盘不';t出现在每个焦点上,reactjs,react-native,autofocus,react-native-paper,Reactjs,React Native,Autofocus,React Native Paper,我正在为我的应用程序使用react native paper的。 每次从一个视图切换到另一个视图时,我都会使用自动对焦属性,因此当我到达屏幕时可以直接键入 但问题是键盘随机出现。。。有时键盘是单独的,有时我必须点击输入以显示键盘 这是我在任何地方使用的输入示例: <TextInput label="Article" value={this.state.article} o

我正在为我的应用程序使用
react native paper
。 每次从一个视图切换到另一个视图时,我都会使用
自动对焦
属性,因此当我到达屏幕时可以直接键入

但问题是键盘随机出现。。。有时键盘是单独的,有时我必须点击输入以显示键盘

这是我在任何地方使用的输入示例:

<TextInput
                    label="Article"
                    value={this.state.article}
                    onChangeText={article => this.setState({article})}
                    onSubmitEditing={this.submitStepSaisie1}
                    autoFocus
                    style={{backgroundColor: 'transparent'}}
                />
在我的文本输入中:

<TextInput ref={this.fieldOne} />

但是当我调用
this.fieldOne.current.focus()时,它返回以下错误:
无法读取null的属性“focus”。

你们有把戏吗? 谢谢

从'react native'导入{TextInput as nativetemput};
this.setState({article})}
onSubmitEditing={this.submitStepSaisie1}
自动对焦
样式={{backgroundColor:'transparent'}}
渲染={(道具)=>}
/>

我没有时间测试,但这可能会起作用。

您可以使用该元素的ref,并在我尝试安装组件后调用focus,但在react native ref中它似乎不再起作用了?当我试图实现它的时候,总是说一些错误。。。或者可能ref在react native paper Element上不起作用到底是什么错误?我刚刚在您的
中编辑了我的问题PASS ref,我最后在焦点函数之前添加了一个超时。。。这是唯一可行的方法。
<TextInput ref={this.fieldOne} />
import { TextInput as NativeTextInput } from 'react-native';

<TextInput
  label="Article"
  value={this.state.article}
  onChangeText={article => this.setState({article})}
  onSubmitEditing={this.submitStepSaisie1}
  autoFocus
  style={{backgroundColor: 'transparent'}}
  render={(props) => <NativeTextInput {...props} ref={this.fieldOne}>}
/>