Replies: 2 comments
-
This may or may not be your case, but if you're trying to get the route params for a route that has no params defined, then when you use Here's how I use it: // We're in a navigator component, that will render child screens. The Navigator has no params defined, so we'll pull params from the child screens
// It's strongly typed too
const route = useRoute<RouteProp<FormsStackParamList, 'FormCreateStack'>>();
const formParams = route.params.params;
const formId = formParams?.formId;
if (!formId) {
throw new Error('Invalid form id');
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
https://reactnavigation.org/docs/typescript/#nesting-navigators you can use the following or CompositeScreenProps const route =
useRoute<
NativeStackScreenProps<HomeStackParams, "InspectionSubStack">["route"]
>() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a nested navigator, so that a Provider wraps only a certain portion of our code.
PARENT Route Stack:
NESTED Route Stack:
when we access the
params
on theInspectionStackParams
route usingconst { params } = useRoute<InspectionRouteProps<'VehicleInspectionStep'>>();
it works fine. Now we have to move the Provider to the top level of the app.Now the params show up as
params.params
.We navigate as:
Why is this showing up now? Typescript doesn't approve of
params.params
either, of course.Beta Was this translation helpful? Give feedback.
All reactions