Skip to content

Commit fb4bc96

Browse files
committed
add replace-use-form-state codemod
1 parent 14a8f94 commit fb4bc96

14 files changed

+220
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import ReactDOM from "react-dom";
2+
3+
function StatefulForm({}) {
4+
const [state, formAction] = ReactDOM.useFormState(increment, 0);
5+
return <form></form>;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import ReactDOM from "react-dom";
2+
3+
function StatefulForm({}) {
4+
const [state, formAction] = ReactDOM.useActionState(increment, 0);
5+
return <form></form>;
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createPortal, useFormState } from "react-dom";
2+
3+
function StatefulForm({}) {
4+
const [state, formAction] = useFormState(increment, 0);
5+
6+
createPortal();
7+
return <form></form>;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createPortal, useActionState } from "react-dom";
2+
3+
function StatefulForm({}) {
4+
const [state, formAction] = useActionState(increment, 0);
5+
6+
createPortal();
7+
return <form></form>;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { useFormState as UFS, createPortal } from "react-dom";
2+
3+
function StatefulForm({}) {
4+
const [state, formAction] = UFS(increment, 0);
5+
6+
createPortal();
7+
return <form></form>;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { useActionState as UFS, createPortal } from "react-dom";
2+
3+
function StatefulForm({}) {
4+
const [state, formAction] = UFS(increment, 0);
5+
6+
createPortal();
7+
return <form></form>;
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { useFormState } from "react-dom";
2+
3+
async function increment(previousState, formData) {
4+
return previousState + 1;
5+
}
6+
7+
function StatefulForm({}) {
8+
const [state, formAction] = useFormState(increment, 0);
9+
return (
10+
<form>
11+
{state}
12+
<button formAction={formAction}>Increment</button>
13+
</form>
14+
);
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { useActionState } from "react-dom";
2+
3+
async function increment(previousState, formData) {
4+
return previousState + 1;
5+
}
6+
7+
function StatefulForm({}) {
8+
const [state, formAction] = useActionState(increment, 0);
9+
return (
10+
<form>
11+
{state}
12+
<button formAction={formAction}>Increment</button>
13+
</form>
14+
);
15+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { other } from "react-dom";
2+
3+
function StatefulForm({}) {
4+
const otherResult = other();
5+
return <div></div>;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { other } from "react-dom";
2+
3+
function StatefulForm({}) {
4+
const otherResult = other();
5+
return <div></div>;
6+
}

0 commit comments

Comments
 (0)