Basic Form of React.
import React, { useState } from 'react'; // JS // const input = document.getElementById('myText'); // const inputValue = input.value // React // value, onChange const ControlledInputs = () => { const handleSubmit = (e) => { e.preventDefault(); console.log('Hello World...'); } return <> <article> <form className="form"> <div className="form-control"> <label htmlFor="firstName"> Name : </label> <input type="text" id="firstName" name="firstName"/> </div> <div className="form-control"> <label htmlFor="email"> Email : </label> <input type="text" id="email" name="email" onClick={handleSubmit}/> </div> <button type="submit">Submit</button> </form> </article> </>; }; export default ControlledInputs;
Above example of react basic form and how can implement it on react project.