react-navigation/react-navigation · error
Couldn't find a screen to navigate to. Make sure to provide
Error message
Couldn't find a screen to navigate to. Make sure to provide a screen name.
What it means
When building the action for a link href, the resolved state has no screen and no action could be derived, so useLinkProps throws because there is nothing to navigate to. This happens when the href parses to an empty state or the linking config maps the path to no screen.
Source
Thrown at packages/native/src/useLinkProps.tsx:348
e.currentTarget && 'target' in e.currentTarget
? [undefined, null, '', '_self'].includes(e.currentTarget.target)
: true;
// let the browser handle the interaction
if (hasModifierKey || !isLeftClick || !isSelfTarget) {
return;
}
}
e?.preventDefault();
let cloned: NavigationAction;
if (action != null) {
cloned = clone(action);
} else {
if (screen == null) {
throw new Error(
"Couldn't find a screen to navigate to. Make sure to provide a screen name."
);
}
cloned = clone(
CommonActions.navigate(
screen,
// @ts-expect-error This is already type-checked by the prop types
params
)
);
if (parent != null) {
cloned = {
...cloned,
target: navigation.getState()?.key,
};
}View on GitHub (pinned to ab1319d6bb)
Solutions
- Provide a non-empty href with a valid screen path, e.g. href="/home".
- Ensure the linking config maps the path to a concrete screen name.
- Validate href construction so template params never yield an empty path.
- Fall back to a default route when href is empty.
Example fix
// before
const href = `/items/${id}`; // id undefined -> '/items/undefined' or ''
// after
const href = id ? `/items/${id}` : '/items'; Defensive patterns
Strategy: validation
Validate before calling
if (!to || !to.startsWith('/')) {
throw new Error(`Invalid link target: '${to}'`);
} Type guard
function isValidHref(to: unknown): to is string {
return typeof to === 'string' && to.length > 1 && to.startsWith('/');
} Try / catch
try {
const { onPress, href } = useLinkProps({ to });
} catch (e) {
if (e instanceof Error && e.message.includes('screen to navigate')) {
navigateFallback('/home');
} else { throw e; }
} Prevention
- Guard href construction so required params are never undefined.
- Ensure linking config maps every emitted path to a concrete screen.
- Add unit tests for getStateFromPath on all link templates.
- Co-locate link templates with route definitions to avoid drift.
When it happens
Trigger: Calling useLinkProps/Link with an href that resolves (via getStateFromPath) to a state lacking a screen name and without a pre-built action — e.g. href='' or href='/' when no initial route is configured.
Common situations: Empty or root-only href strings passed to Link; linking config where getStateFromPath returns partial/empty state for the path; dynamically built hrefs that end up empty due to undefined route params.
Related errors
- Failed to parse href '${href}' to a navigation state.
- Expected the configuration to be an object, but got ${JSON.s
- Found invalid properties in the configuration: ${validationE
- Found invalid path '${path}'. The 'path' in the top-level co
- Couldn't find a LinkingContext context.
AI-assisted analysis of react-navigation/react-navigation@ab1319d6bb (2026-08-31).
Data as JSON: /api/errors/3ed1f82829da6a32.
Report an issue: GitHub.