[英]Share data in different component in react native
我將數據存儲在從 textinput 獲取的組件中
用戶詳細信息.js
class UserdetailsScreen extends Component {
constructor(props) {
super(props)
this.state = {
name: '',
number: ''
}
}
render() {
return (
<View style={styles.view}>
<Text>Enter name: </Text>
<TextInput style={styles.input}
placeholder='Name Surname'
onChangeText={ (value) => this.state.name = value}/>
<Text>Enter mobile number: </Text>
<TextInput style={styles.input}
placeholder='830xxxxxxx'
onChangeText={ (value) => this.state.number = value}/>
<Button
title="Continue"
onPress={() => this.continueOnFoodScreen()}
color='orange'
/>
</View>
)
}
}
我需要在不同的組件中提取這些數據,例如:finalscreen.js
如何在 finalscreen.js 中打印此數據“名稱”和“編號”
我將數據存儲在從 textinput 獲取的組件中
用戶詳細信息.js
class UserdetailsScreen extends Component {
constructor(props) {
super(props)
this.state = {
name: '',
number: ''
}
}
render() {
return (
<View style={styles.view}>
<Text>Enter name: </Text>
<TextInput style={styles.input}
placeholder='Name Surname'
onChangeText={ (value) => this.state.name = value}/>
<Text>Enter mobile number: </Text>
<TextInput style={styles.input}
placeholder='830xxxxxxx'
onChangeText={ (value) => this.state.number = value}/>
<Button
title="Continue"
onPress={() => this.continueOnFoodScreen()}
color='orange'
/>
</View>
)
}
}
我需要在不同的組件中提取這些數據,例如:finalscreen.js
如何在 finalscreen.js 中打印此數據“名稱”和“編號”
我將數據存儲在從 textinput 獲取的組件中
用戶詳細信息.js
class UserdetailsScreen extends Component {
constructor(props) {
super(props)
this.state = {
name: '',
number: ''
}
}
render() {
return (
<View style={styles.view}>
<Text>Enter name: </Text>
<TextInput style={styles.input}
placeholder='Name Surname'
onChangeText={ (value) => this.state.name = value}/>
<Text>Enter mobile number: </Text>
<TextInput style={styles.input}
placeholder='830xxxxxxx'
onChangeText={ (value) => this.state.number = value}/>
<Button
title="Continue"
onPress={() => this.continueOnFoodScreen()}
color='orange'
/>
</View>
)
}
}
我需要在不同的組件中提取這些數據,例如:finalscreen.js
如何在 finalscreen.js 中打印此數據“名稱”和“編號”
我將數據存儲在從 textinput 獲取的組件中
用戶詳細信息.js
class UserdetailsScreen extends Component {
constructor(props) {
super(props)
this.state = {
name: '',
number: ''
}
}
render() {
return (
<View style={styles.view}>
<Text>Enter name: </Text>
<TextInput style={styles.input}
placeholder='Name Surname'
onChangeText={ (value) => this.state.name = value}/>
<Text>Enter mobile number: </Text>
<TextInput style={styles.input}
placeholder='830xxxxxxx'
onChangeText={ (value) => this.state.number = value}/>
<Button
title="Continue"
onPress={() => this.continueOnFoodScreen()}
color='orange'
/>
</View>
)
}
}
我需要在不同的組件中提取這些數據,例如:finalscreen.js
如何在 finalscreen.js 中打印此數據“名稱”和“編號”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.