Learning TypeScript has brought me to new discoveries. While exploring a random project online today, I stumbled upon this intriguing piece of code in a TypeScript file:
import { Route, useRoute } from "@react-navigation/native"
import { NewAppointmentConfirmationScreenProps } from "@app/screens/new-appointment-confirmation/types"
export const useNewAppointmentConfirmationScreenRoute = () =>
useRoute<Route<"NewAppointmentConfirmationScreen", NewAppointmentConfirmationScreenProps>>()
This function is unfamiliar to me! Can someone explain what this line means:
useRoute<Route<"NewAppointmentConfirmationScreen", NewAppointmentConfirmationScreenProps>>()
I understand that a component looks like <abc/>
, but why is there a function name followed by angle brackets (less-than/greater-than signs)?