1.0.1 • Published 3 years ago

react-form-init v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Go to your src folder and iniside your form components : import React, { useState } from 'react' import { getData, getErrors } from 'react-form-init';

function Home() { const data, setData = useState()

const handleSubmit = (e) =>{
    e.preventDefault();
    let doc = document.getElementById("form");
    setData(getData(doc))// getData() function will return the data inside the form passed.
} 

return (
    <div>
        <form id="form" onSubmit={handleSubmit}>
            <input type="text" id="lname" placeholder="Enter your First name" />
            <input type="text" id="fname" placeholder="Enter your Last Name" />
            <input type="submit" value="Submit" />
        </form>

    </div>
)

}