user14877357
user14877357

Reputation:

navigation.getParam is not a function. (In 'navigation.getParam('message', 'hiiii')', 'navigation.getParam' is undefined) in react native

I am new to react native. I want to send API data from one screen to another screen And want to display that data on that screen. but I am getting error like = navigation.getParam is not a function. (In 'navigation.getParam('message', 'hiiii')', 'navigation.getParam' is undefined). please help , thanks.

here is my first screen code from where I send data

class Browse extends Component {

  constructor(props) {
    super(props);
    this.state = {

      ListView:[]
    };
  }


  state = {
    categories: [],
    error: [],
  };

   ListView () {
     const {navigation} = this.props

   AsyncStorage.multiGet(["application_id", "created_by"]).then(response => {

         console.log(response[0][1]) // Value1

         console.log(response[1][1]) // Value2


    fetch("https://xys.tech/Android_API_CI/get_lead_data_for_user", {
      method: "POST",
      headers: { 'Accept': 'application/json, text/plain, */*', "Content-Type": "application/json" },
      body: JSON.stringify([{ id:response[1][1], application_id:response[0][1]}]),
    })
      .then((returnValue) => returnValue.json())
        .then((response)  => {
        alert(JSON.stringify(response))
            this.props.navigation.navigate("ListView", {
               message: "hiiiii",
            });
      })

here is my second screen code where I want to show API data

const { width } = Dimensions.get("window");
    class Browse extends Component {
  
constructor(props) {
  super(props);
  this.state ={
    Email:"",
  }
render() {
    const { profile, navigation } = this.props;
    const tabs = [""];
    const ListView = navigation.getParam('message','hiiii')
    //const route = this.props

    return (
      <View style={{flex: 1}}>
        <ScrollView>{ListView}</ScrollView>
      </View>
    );
  }
}

Upvotes: 0

Views: 171

Answers (1)

Jagjeet Singh
Jagjeet Singh

Reputation: 505

Try with route like this

this.props.route.params.message

Upvotes: 1

Related Questions