I'm developing a Mobile Application using React Native. There, I'm passing something when navigating to the second page.
So, assume my first screen has something like this.
export default function firstScreen(props) {
return(
//data is a custom object variable that may be changed.
<Button onPress={() => props.navigation.navigate('SecondScreen', { data: data } )} />
)
}
On my second screen, assume there is something like this...
export default function secondScreen(props) {
const { data } = props.navigation.state.params;
useEffect(() => {
console.log(data);
}, [data])
return(
//content
)
}
My problem is, when data is changed from the first screen, the second screen does not listen to that change and print the content of the data variable on the console.
So, I want to know, how to listen to the navigation state changes in React Native.