Browser Refresh required after form updates with Prisma
Unanswered
Giant panda posted this in #help-forum
Giant pandaOP
Here is a snippet:
async function updateForm(data: FormData) {
"use server"
await updateTodo(data)
}
..from updatetodo.js
export async function updateTodo(data: FormData ) {
'use server'
const title = data.get("title")?.valueOf()
if (typeof title !== "string" title.length === 0)
throw new Error('title issues')
const uid = data.get("id")?.valueOf()
if (typeof uid !== "string" uid.length === 0)
throw new Error('uid issues')
await prisma.todo.update({ where: { id:uid }, data: { title } })
}
afterwards I have to refresh the browser for the new data to show in my UI?
async function updateForm(data: FormData) {
"use server"
await updateTodo(data)
}
..from updatetodo.js
export async function updateTodo(data: FormData ) {
'use server'
const title = data.get("title")?.valueOf()
if (typeof title !== "string" title.length === 0)
throw new Error('title issues')
const uid = data.get("id")?.valueOf()
if (typeof uid !== "string" uid.length === 0)
throw new Error('uid issues')
await prisma.todo.update({ where: { id:uid }, data: { title } })
}
afterwards I have to refresh the browser for the new data to show in my UI?
2 Replies
Giant panda
You can call
revalidatePath to update the UI from the server-side by rerunning the RSCs@Giant panda You can call `revalidatePath` to update the UI from the server-side by rerunning the RSCs
Giant pandaOP
Nice! That worked. Thank you very much!!!!