On the submit button, I am calling one API after successfully run I want to send data to another activity in the react-native.
I tried following source code, I am a newbie in react-native.
What I have tried:
On submit I am calling this function.
Submit(navigation) {
fetch(`http://xxxxxx.com/api/LoveCalculatro?nm1=${this.state.yourName}&nm2=${this.state.parName}`
)
.then(response => response.json())
.then(json => {
console.log(json);
this.setState({
result:json
})
this.props.navigation.navigate('display',this.props.result)
})
.catch(error => {
console.error(error);
});
}
when i am using console i get values in the "result" variable. so i am trying to pass another activity like this.
this.props.navigation.navigate('display',this.props.result)
but i am not getting values in this activity. this is another activity where i want to get data
const DisplayResult =(props)=>{
console.log(props.firstName)
console.log("display screen")
return (
{props.data.firstName} {props.data.secondName}
{props.data.amount}
{props.data.result}
)
}
export default DisplayResult;