_ankri
_ankri
TTCTheo's Typesafe Cult
Created by Kyle on 6/27/2023 in #questions
How to get data from server action
You can do
<form action={(formData) => {
const user = await createUser(formData);
console.log(user);
}}
>
</form>
<form action={(formData) => {
const user = await createUser(formData);
console.log(user);
}}
>
</form>
More info: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions#props Or: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions#experimental-useoptimistic (just ignore the optimistic stuff)
5 replies
TTCTheo's Typesafe Cult
Created by mattddean on 6/27/2023 in #questions
Detect server/client component
I am sorry that I don't have an answer to your question, but I was curious and tried it myself. My idea was to "hack" my way around it by declaring Hero as a ErrorBoundary. My thought was to render ServerComponent when the ErrorBoundary catches something, otherwise a ClientComponent. But Class components are Client Components and need a "use client" .
18 replies