diff --git a/packages/native/src/useLinkBuilder.tsx b/packages/native/src/useLinkBuilder.tsx index 6094cfaf..0d5e9917 100644 --- a/packages/native/src/useLinkBuilder.tsx +++ b/packages/native/src/useLinkBuilder.tsx @@ -52,14 +52,18 @@ export default function useLinkBuilder() { (name: string, params?: object) => { const { options } = linking; - // If we couldn't find a navigation object in context, we're at root - // So we'll construct a basic state object to use + if (options?.enabled === false) { + return undefined; + } + const state = navigation ? getRootStateForNavigate(navigation, { index: 0, routes: [{ name, params }], }) - : { + : // If we couldn't find a navigation object in context, we're at root + // So we'll construct a basic state object to use + { index: 0, routes: [{ name, params }], }; diff --git a/packages/native/src/useLinkProps.tsx b/packages/native/src/useLinkProps.tsx index d90ba1bd..e907fdfa 100644 --- a/packages/native/src/useLinkProps.tsx +++ b/packages/native/src/useLinkProps.tsx @@ -49,6 +49,14 @@ export default function useLinkProps({ to, action }: Props) { throw new Error("Couldn't find a navigation object."); } } else { + if (typeof to !== 'string') { + throw new Error( + `To 'to' option is invalid (found '${String( + to + )}'. It must be a valid string for navigation.` + ); + } + linkTo(to); } }