throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().') #82655
-
Hi, I'm learning Next.js and I found this error 'by accident' when I was looking at the regenerated HTML. I'm using Server Actions as they suggest on the learning page and I'm following exactly all the steps - https://nextjs.org/learn/dashboard-app/mutating-data I'll try to explain below: (Sorry my english) I have the website runing here (where the error occurs): https://aprendendo-nextjs-dashboard.netlify.app/dashboard/invoices When you click the Delete button it deletes the invoice, and reloads the table, and then you can see the error on the regenarated HTML as follows: (Sometimes the errors appears on page loading) But the delete button still works if you want to delete other invoices. Here is the repository: https://github.com/andreydjason/aprendendo-nextjs-dashboard - it is pretty much the same as where they teach how to do it: https://nextjs.org/learn/dashboard-app/mutating-data
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi, This looks suspicious... I was able to reproduce with just: import { foo } from "./actions";
export default function Home() {
return (
<form action={foo}>
<button type="submit">Submit</button>
</form>
);
} And 'use server';
import { revalidatePath } from "next/cache";
export async function foo(data: unknown) {
console.log({ data })
revalidatePath("/foo")
} The revalidatePath is the key thing here it seems - 🤔 I'll ask around. |
Beta Was this translation helpful? Give feedback.
-
I'm leaving this here open so anyone can find it easily, as I could not find a proper and definitive answer like this one above anywehere else. Thanks again @icyJoseph. |
Beta Was this translation helpful? Give feedback.
So like, following from the code comment, I guess this is likely harmless ~ though, maybe we'll look into this a bit more.