Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
JavaScript
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)
        })
       // this.navigation.navigate('DisplayLove');
     // })
     
      .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.
JavaScript
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
JavaScript
const DisplayResult =(props)=>{
  console.log(props.firstName)
    console.log("display screen")
    //render(props)
    //{
        return (
                {props.data.firstName}  {props.data.secondName}
                {props.data.amount}
                {props.data.result}
        )
 //   }
    }
    export default DisplayResult;
Posted
Updated 11-Apr-20 23:40pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900