ract js forms code example
Example: form in react js
import React, { useState } from "react";
export function Form() {
const [name, setName] = useState("");
const handleSubmit = (evt) => {
evt.preventDefault();
alert(`Submitting Name ${name}`)
}
const changeName = (e) => {
setName(e.target.value)
}
return (
<form onSubmit={handleSubmit}>
<br />
<br />
<label>
Frirst Name:
<input
type="text"
value={name}
onChange={changeName}
/>
</label>
<input type="submit" value="Submit" />
</form>
);
}
export default Form;