Skip to content

Commit

Permalink
warn about useless prefetch if action is a function
Browse files Browse the repository at this point in the history
  • Loading branch information
lubieowoce committed Jul 30, 2024
1 parent 4c377ae commit a8b2d6d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/next/src/client/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ export type FormProps = {
export default function Form({
replace,
scroll,
prefetch = null,
prefetch: prefetchProp,
ref: externalRef,
...props
}: FormProps) {
const actionProp = props.action
const isNavigatingForm = typeof actionProp === 'string'
const prefetch = prefetchProp ?? null

for (const key of DISALLOWED_FORM_PROPS) {
if (key in props) {
Expand Down Expand Up @@ -120,6 +121,11 @@ export default function Form({
' `router.replace()` - https://nextjs.org/docs/app/api-reference/functions/use-router#userouter\n'
)
}
if (prefetchProp !== undefined) {
console.error(
'Passing `prefetch` to a <Form> whose `action` is a function has no effect.'
)
}
}
return <form {...props} ref={ownRef} />
}
Expand Down

0 comments on commit a8b2d6d

Please sign in to comment.