Skip to content

Commit

Permalink
chore: throw error when prefetch props is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Dec 12, 2024
1 parent 46f2d38 commit 5873b48
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/renderer-react/src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ export const LinkWithPrefetch = React.forwardRef(
) => {
const { prefetch: prefetchProp, ...linkProps } = props;
const prefetch =
prefetchProp === true
(prefetchProp === true
? 'intent'
: prefetchProp === false
? 'none'
: prefetchProp;
: prefetchProp) || 'none';
if (!['intent', 'render', 'viewport', 'none'].includes(prefetch)) {
throw new Error(
`Invalid prefetch value ${prefetch} found in Link component`,
);
}
const appData = useAppData();
const to = typeof props.to === 'string' ? props.to : props.to?.pathname;
const hasRenderFetched = React.useRef(false);
Expand Down

0 comments on commit 5873b48

Please sign in to comment.