Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React Native Typescript, pass variable to another screen

$
0
0

I cant seem to figure how to pass variable with typescript in react native, I have tried the params but its saying undefined is not an object (evaluating 'navigation.props.value').

below are the codes.

import {useNavigation} from '@react-navigation/core';const navigation = useNavigation();.......<TouchableOpacity onPress={() => navigation.navigate('NewsDetails', {value: 'hi', })}><Block row flex={0} align="center"><Text                      p                      color={colors.link}                      semibold                      size={sizes.linkSize}                      marginRight={sizes.s}>                      Read Article</Text><Image source={assets.arrow} color={colors.link} /></Block></TouchableOpacity>

then to display it in screen be this is what I had done but its not working

<Text p marginBottom={sizes.s}>               {navigation.props.value}</Text>

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>