-
Notifications
You must be signed in to change notification settings - Fork 49.2k
Open
Description
The controlled component also resets the "select" after the action is triggered.
but the "input" component does not.
"use client";
import { useActionState, useState } from "react";
function add() {
return Date.now();
}
export default function Page() {
const [state, formAction] = useActionState(add, 0);
const [name, setName] = useState("");
const [type, setType] = useState("2");
return (
<form action={formAction}>
<p>{state}</p>
<p>
<input
type="text"
value={name}
onChange={(e) => setName(e.target.value)}
/>
</p>
<p>
<select
name="gender"
value={type}
onChange={(e) => setType(e.target.value)}
>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</p>
<button>submit</button>
</form>
);
}
Repro: https://codesandbox.io/p/sandbox/stupefied-cohen-n578l6
bumling, Meryovi, MiroslavPetrik, joemaffei, flyingduck92 and 27 morekarolskolasinski