Trouble using server action on client component
Unanswered
vsw posted this in #help-forum
vswOP
I have a standard
logout
server action that I want to use onclick, how can I do this client-side?4 Replies
vswOP
NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Error source:
"use client";
...
<DropdownMenuItem
onClick={async () => {
await logout();
router.push("/");
}}
>
<LogOut />
Log out
</DropdownMenuItem>
Logout server action:
export async function logout() {
const supabase = await createClient();
await supabase.auth.signOut();
revalidatePath("/", "layout");
}
@vsw NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Error source:
jsx
"use client";
...
<DropdownMenuItem
onClick={async () => {
await logout();
router.push("/");
}}
>
<LogOut />
Log out
</DropdownMenuItem>
Logout server action:
jsx
export async function logout() {
const supabase = await createClient();
await supabase.auth.signOut();
revalidatePath("/", "layout");
}
have you tried using <button> instead of <DropdownMenuItem> ?