Im trying to update the status with redux, but when I want to display the value of "This.props.user.status", I receive an empty string I used the props value to update TextInput (and it works) but it does not work with checkbox Any ideas..?
OnSignUp=>{
console.log("this.props.user.status => "+this.props.user.status)
}
onPressss(status) {
this.setState({ parent: true, status: status });
}
render() {
return (
<View>
<TextInput
placeholder={"Email"}
value={this.props.user.emailUser}
onChangeText={emailUser=> this.props.updateEmail(emailUser)}
/>
<CheckBox
checked={this.state.parent}
onPress={() => this.onPressss("Parent")}
value={"Parent"}
onChangeText={status=> this.props.updateStatus(status)}/>
<TouchableOpacity onPress={() => this.OnSignUp()}>
<Text>Save</Text>
</TouchableOpacity >
</View>
)}
const mapStateToProps = (state) => {
return {
user:state.user
};
};
const mapDispatchToProps = (dispatch) => {
return {
updateStatus: (user) =>
dispatch({ type: "UPDATE_STATUS", payload: user}),
};
};
export default wrapper(SignUp);
Aucun commentaire:
Enregistrer un commentaire