I've set the location as session variable at user registration (index.js
) using AsyncStorage.setItem
. I am trying to access this session variable in Profile.js
. But when i tried to print the session variable (location) nothing is getting.Following is my code.What wrong i'm doing? please help
index.js
AsyncStorage.setItem('location').then((location) =>{
this.setState({ location: location })
})
Profile.js
fetch('http://loaclhost/apps/requirement.php',{
method:'POST',
headers: {
'Accept':'application/json' ,
},
body: JSON.stringify({
location:this.state.location,
})
}).then( () =>
{
response => response.json();
AsyncStorage.getItem('location').then((location) => {
this.setState({location: location})
})
render(){
return(
<Container>
<View>
<TextInput
value={this.state.loctaion} />
</View>
</Container>
);
}
This may help you,
index.js
Profile.js