import React from 'react';
import { useForm }from './FormHook';
export default const RandomForm = () => {
const { formState, handleInputChange } = useForm({
email: "",
password: "",
});
const {email, password} = formState;
const handleSubmit = (e) => {
e.preventDefault();
// Do as you wish :)
}
return(
<form onSubmit={handleSubmit}>
<input
type="email"
name="email"
value={email}
onChange={handleInputChange}
/>
<input
type="password"
name="password"
value={password}
onChange={handleInputChange}
/>
<button>Submit</button>
</form>
)
}
PedroNunezCode/ReactFormHook
Tired of setting state? writing on change function for every component? LOOK NO FURTHER. Hope this helps someone out as much as it helps me :)
JavaScript