React native 使用来自另一屏幕的数据将值绑定到TextInput-React Native
我试图使用React native 使用来自另一屏幕的数据将值绑定到TextInput-React Native,react-native,react-native-android,React Native,React Native Android,我试图使用导航将数据传递到另一个屏幕,但似乎不起作用: componentDidMount() { const { navigation } = this.props; const phoneNumber = navigation.getParam('phoneNumber'); this.setState({phoneNumber: phoneNumber }); } 视图: this.setState({phoneNumber})}/> 不工作是什么意思?您无法在did
导航将数据传递到另一个屏幕,但似乎不起作用:
componentDidMount() {
const { navigation } = this.props;
const phoneNumber = navigation.getParam('phoneNumber');
this.setState({phoneNumber: phoneNumber });
}
视图:
this.setState({phoneNumber})}/>
不工作是什么意思?您无法在didMount中获取电话号码
,或者您无法在更改文本时更改状态
?如何设置phoneNumber
导航参数?我得到phoneNumber,但它不绑定到输入。您是否使用TextInput
组件?因为您在代码处附加了Input
,但在问题标题处,您编写了TextInput
我正在使用Input您从何处导入“Input”这是自定义组件吗?
<Input value={this.state.phoneNumber} onChangeText={(phoneNumber) => this.setState({phoneNumber})} />