On Screen A, there is a value to keep track of loading of a GraphQL mutation. I want to pass that loading value to Screen B. My problem is that when I try to pass that value as a param to Screen B using navigation.navigate(ScreenB, { loading }), the value of loading does not update - it always remains as whatever the value was at the moment that navigation.navigate was invoked.
I know that setParams updates the param for a given route, but it does not seem to apply to my use case because it does not alter the param between routes. Is there any way that the previous screen can dynamically set the param so that I can recuperate the changed value while on the current screen?
const ScreenA = (props) => {
const { data, loading } = useQuery(QUERY);
(
<View>
<Button onPress={() => navigation.navigate(ScreenB, { loading } }/>
</View>
)
}
const ScreenB = (props) => {
const screenALoading = navigation.getParam('loading');
return (
<Text>{loading}</Text>
)
}