We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 62f0fe1 commit 2ef98ccCopy full SHA for 2ef98cc
1 file changed
react/useActionState/src/components/FormComponent.tsx
@@ -0,0 +1,21 @@
1
+"use server";
2
+
3
+import { useActionState } from "react";
4
5
+async function handler(previousState: number, data: FormData) {
6
+ console.log({ data })
7
+ return previousState + 1;
8
+}
9
10
+export function FormComponent() {
11
+ const [state, formActionHandler] = useActionState(handler, 0);
12
13
+ return (
14
+ <>
15
+ <div className="state">{state}</div>
16
+ <form action={formActionHandler} method="post">
17
+ <button>Submit</button>
18
+ </form>
19
+ </>
20
+ );
21
0 commit comments