Ok, I may not understand the true purpose of the revalidatePath
function.
I am trying to clear a form’s fields after the form is submitted, but using revalidatePath
in a Server Actions file has no effect - nothing happens.
The actions are imported into the form, which is then imported into a page. Also, the form successfully sends the data to my Vercel Postgres store.
How can I get the form to actually reset (clear the fields) after submission?
/actions/actions.js file I’m testing with:
"use server"
import prisma from "/lib/prisma"
import { revalidatePath } from "next/cache";
export async function createRando(formData) {
await prisma.InternetRando.create({
data: {
rando_name: formData.get('name'),
rando_email: formData.get('email'),
rando_message: formData.get('message'),
}
});
revalidatePath('/contact', 'page')
}
Thanks for any guidance!