【发布时间】:2018-09-10 23:50:23
【问题描述】:
因为我正在构建我的第一个 React 应用程序,特别是 react-native 应用程序。我想将文本框值从一个 js 文件传递到另一个。有人可以帮我怎么做吗?
我在 first.js 中的代码
<Text style={{ color: 'black', fontSize: 20, textAlign: 'left', width: width - 60 }}>{GLOBAL.Email}</Text>
<View style={[styles.textInputFrame, { width: width - 48, }]} >
<TextInput
keyboardType='email-address'
style={styles.textInput}
onChangeText={(email) => this.setState({ email })}
returnKeyType='next'
onSubmitEditing={() => this.refs.passwordInput.focus()}
underlineColorAndroid='transparent'
/>
</View>
提前谢谢你
【问题讨论】:
-
你能更清楚
one js file to another是什么意思吗?你的意思是说Components? -
如果您想将信息从一个
component传递到另一个component,您可以将其作为prop传递。如果该值不会仅用于另一个component/文件,我建议您考虑使用Context或Redux
标签: javascript android ios reactjs react-native