Reputation: 1952
I am new to this React native and javascript as a whole. I am trying to pass data from one screen to another using wix react native navigation. Here is my code On screen one
_gotoAnotherScreen = (screen,data) => {
this.props.navigator.push({
screen: screen,
title: data.title,
passProps: {
data: data
}
});
};
And my data is an array
And on the 2nd screen i am trying to catch the value like this
const { params } = this.props.navigator;
console.log(params);
This is saying undefined
Can anyone please tell me how i can catch the data.
I tried to follow this thread , Passing Data Using React-Native Navigation But those ansers giving me error saying trying to get property of undefined.
Any help please . Thank you
Upvotes: 2
Views: 2443
Reputation: 4178
At First screen. Pass param like this.
this.props.navigation.navigate({
screen: "SecondScreen",
params: { data: data }
});
At second screen, You can catch param value like this.
componentDidMount() {
const {data} = this.props.navigation.state.params;
}
Upvotes: 1
Reputation: 1952
After lot of looking here and there and some trial and error i found out.
it can used just like any other object.
like this this.props.data
Upvotes: 1