I have the query _getCurrentUserInfo with which I get the email of the user who logs into my application in the info variable. I have another component that generates QR, I want to pass the email that I have inside the info variable as a value to generate it. How could I do it? I'm still a newbie, I haven't used redux. Is there a "simple" way?
const _getCurrentUserInfo = async () => {
try {
**let info = await GoogleSignin.signInSilently();
//console.log(info.user.email)**
const userRol = await AsyncStorage.getItem("user_rol");
if (!userRol) {
axios.post('https://ballin-api-stage.herokuapp.com/users',info.user)
.then((response) =>AsyncStorage.setItem("user_rol",response.data.data.rol))
.then((error) =>console.log(error))
}
else if (userRol==="admin") {
console.log("admin")
console.log(userRol)
}
else {
console.log(userRol)
}
setUserInfo(info);
} catch (error) {
if (error.code === statusCodes.SIGN_IN_REQUIRED) {
alert('User has not signed in yet');
console.log('User has not signed in yet');
} else {
alert("Unable to get user's info");
console.log("Unable to get user's info");
}
}
};
export default class QrGenerator extends Component {
constructor()
{
super()
this.state = {
value: ""
}
}
render() {
return (
<View>
<QRCode
value={this.state.value}
/>
</View>
);
Although I have seen that it is not the most correct, I have tried creating info as a global variable, but it could not pass the data. Thank you!