Ich entwickle nur einige app mit reagieren native und in meinem Code Ich erhalte nur Handy im Zustand .wie, um diesen Zustand in global und in einem anderen Bildschirm wie OTP-Bildschirm, wie man dies verwenden ein anderer Bildschirm. Ich benutze reactive native Router Flux. Kann ich diese Daten im nächsten Bildschirm als zweite Variable senden?globalen Zustand reagieren native
reagieren nativen 0,049
PhpStorm
android Studio
export default class Login extends Component{
constructor(props) {
super(props);
this.state = {mobile: ''};
this._OtpButton = this._OtpButton.bind(this);
}
_OtpButton() {
fetch("https://2d44f003.ngrok.io/mobileWebViews/v1/sendOtp/", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({
mobile:this.state.mobile,
type:'otp'
})
})
.then(response => response.json())
.then(responseJson => {
if(responseJson.status.toString() === 'ok'){
// this.global.mobile = mobile;
Alert.alert('پیامک ارسال شد');
Actions.replace('OTP');
}else if(responseJson.status.toString() === 'fail') {
Alert.alert(responseJson.message.toString());
}else{
Alert.alert(responseJson.message.toString());
console.log(responseJson.message)
}
})
.catch(error => {
Alert.alert("Error"+JSON.stringify(error));
// console.error(error);
})
}
render() {
return (
<View style={styles.container}>
<Image source={require("./assets/img/login.jpg")}
style={{
flex: 1,
position: 'absolute',
width: '100%',
height: '100%',
justifyContent: 'center',
}}
/>
<View style={styles.LoginBox}>
<Text style={styles.LoginTitel}> ورود به بوتیک</Text>
<View style={styles.inputGroups}>
<TextInput
style={styles.inputText}
underlineColorAndroid='transparent'
placeholder="شماره موبایل (مثال ۰۹۱۲۱۲۳۴۵۶۷)"
keyboardType={'numeric','number-pad'}
onChangeText={(mobile) => this.setState({mobile})}
/>
</View>
<TouchableOpacity activeOpacity={.8} onPress={this._OtpButton}>
<Text style={styles.ButtonEnter}>دریافت رمز از طریق پیامک</Text>
</TouchableOpacity>
<TouchableOpacity activeOpacity={.8} onPress={()=>Actions.replace('Login2')}>
<Text style={styles.ButtonPass}>ورود با نام کاربری و پسورد</Text>
</TouchableOpacity>
<Text> </Text>
<TouchableOpacity activeOpacity={.8} onPress={()=>Actions.replace('register')} >
<Text style={styles.forgetPass}>ثبت نام فروشگاه جدید</Text>
</TouchableOpacity>
</View>
<Image/>
</View>
);
}
}
Blick in Redux. – gravityplanx