I'm using React Native and React Navigation. I'm attempting to only make one of my screens into mode="Modal, but the route params I pass when navigating are getting "undefined" with the error TypeError: undefined is not an object (evaluating 'route.params.title'). Why is this and how can I fix this?
My Attempt
const ModalScreen = () => (
<Modals.Navigator mode="modal">
<Modals.Screen
name="Modal"
component={Modal}
options={({ route }) => ({
title: route.params.title,
headerTransparent: true,
gestureResponseDistance: {
vertical: 500,
},
})}
/>
</Modals.Navigator>
);
const MainScreen = () => (
<Items.Navigator>
<Items.Screen
name="Main"
component={Main}
options={{ headerShown: false }}
/>
<Items.Screen name="Modal" component={ModalScreen} />
</Items.Navigator>
);
// Navigating to Modal in another file.
<TouchableOpacity
onPress={() =>
navigation.navigate("Modal", {
screen: "Modal",
title: title,
})
}
>