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

How to pass props with navigation in react native using typescript

$
0
0

I have a login page, after logging in I am able to navigate to my home page. But I also want to pass props when navigating to home page.

Login Page:

const [daysLeft, setDaysLeft] = useState(14);const getHome = () => {  props.navigation.replace(NavigateTo.Main, {screen: NavigateTo.Home, daysLeft: daysLeft});};

After this I am running my login api, and checking if phone is verified or not:

if (!user.is_phone_verified) {  getEmailVerification();} else {  getHome();}

Here my phone is verified and my getHome() is executed, taking me to my home page.

Home Page:

const HomeScreen = (props: any) => {useEffect(() => {    console.log("days: ",props.daysLeft);  }, []); // Remaining code

But I am getting days: undefined in my console. I am new to using react native and I have been trying to figure out what I am doing wrong, but I don't know what I am doing wrong. Please help me.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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