My Goal:
I'm trying to add Typescript typings, but having an issue with route.params.fullName
. When I console.log(route.params)
, the object { fullName: 'John Smith' }
is logged. Why is Typescript having an issue with fullName
?
The weird part is that the code works and when I navigate to the screen, the header title is updated with route.params.fullName
.
Error:
Property 'fullName' does not exist on type 'object'.
Functional Component:
// React Hooks: React Navigation const route = useRoute(); // React Hooks: Lifecycle Methods useEffect(() => { console.log(route.params); // React Navigation: Set Options props.navigation.setOptions({ // ISSUE HERE title: route.params.fullName, }); }, [props.navigation, route.params]);