import { useState } from "react";
function App() {
const [value, setValue] = useState("");
const onChange = (event: React.FormEvent<HTMLInputElement>)
=> {
setValue(event.currentTarget.value);
};
const onSubmit = (event: React.FormEvent<HTMLFormElement>)
=> {
event.preventDefault();
console.log("hello", value);
};
return (
<div>
<form onSubmit={onSubmit}>
<input
value={value}
onChange={onChange}
type="text"
placeholder="username"
/>
<button>Log in</button>
</form>
</div>
);
}
export default App;
event: React.FormEvent<HTMLInputElement>
event: React.FormEvent<HTMLFormElement>
에 주목하기. 나머지는 비슷