I am currently working on passing values from one page to another using navigation. I have attempted the following code:
this.props.navigation.navigate('welcome',
{JSON_ListView_Clicked_Item:this.state.email,}))
in the parent class where I am sending it.
const { navigation } = this.props;
const JSON_ListView_Clicked_Item =
navigation.getParam('JSON_ListView_Clicked_Item', 'NO-ID');
<Text>JSON_ListView_Clicked_Item:
{JSON.stringify(JSON_ListView_Clicked_Item)}</Text>
This is the second class where I want the data to be displayed.
Here is my code:
this.state = { email: '', password: '', error: ''};
firebase.auth()
.signInWithEmailAndPassword(email,
password).then(this.onLoginSuccess.bind(this))
.then(() => this.props.navigation.navigate('welcome',
{JSON_ListView_Clicked_Item:this.state.emai
l,}))
Setting up the text input:
<TextInput
style={{height: 40,width:250, borderRadius: 5
,multiline:"true",borderColor: 'purple',
borderWidth: 2,
}}
value={this.state.email}
secureTextEntry={false}
onChangeText={email => this.setState({ email })}
placeholder="email"
onSubmitEditing={() => {
this.focusNextField('Password');
}}
returnKeyType={ "next" }
ref={ input => {
this.inputs['email'] = input;
}}
/>
Setting up the text input on the second class to retrieve the data:
renderComponent() {
const { navigation } = this.props;
const JSON_ListView_Clicked_Item =
navigation.getParam('JSON_ListView_Clicked_Item', 'NO-ID');
if (this.state.loggedIn) {
return (
<View>
<Text>JSON_ListView_Clicked_Item:
{JSON.stringify(JSON_ListView_Clicked_Item)}</Text>
<Button
title="Sign out"
onPress={() => firebase.auth().signOut()}
/>
</View>
);
Upon testing, I found that I am receiving blank data on the second page. My goal is to successfully pass the email when clicking the button on the first page.