I'm very new to React Native and TypeScript so forgive me if the the question is trivial.
In my application I have a screen to which I'm navigating with React-Navigation
I'm also passing a callback function through the navigation.
navigation.navigate('BluredSuccess', {blurredSuccessCallback})
I show the BlurredScreen for 2 secs and then I close using navigation.pop
and call the callback function like this:
import { NavigationScreenProp } from 'react-navigation';import { Route } from '@react-navigation/native';interface Props { navigation?: NavigationScreenProp, route: Route<any>}const LoginOtpSuccess : React.FC<Props> = ({navigation, route: {params}}) => { React.useEffect(() => { setTimeout(() => { navigation.pop() params.blurredSuccessCallback() // here I see an error. }, 2000) }) return (<View style={styles.container}><BlurView style={styles.absolute} blurType="light" blurAmount={40} reducedTransparencyFallbackColor="white" /><Image source={require('../../../assets/otp_success.png')} style={{width:90, height:90}}></Image></View> )}
Now the code works in general but I keep seeing an error on my callback method stating:
Property 'blurredSuccessCallback' does not exist on type 'object'.
I also see Object is possibly 'undefined'.
on the params variable.
How can I fix this error? What should be the correct types of navigation
and route
in my Props
interface I don't think using any is the correct way.