File size: 518 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import React from 'react';
import { useForm } from 'react-hook-form';
const Input = React.forwardRef(({ name }, ref) => {
return <input ref={ref} name={name} />;
});
export default function App() {
const { register, handleSubmit } = useForm();
const onSubmit = (data, event) => {
console.log(data);
};
return (
<form onSubmit={handleSubmit(onSubmit)}>
<Input ref={register} name="firstName" />
<Input ref={register} name="lastName" />
<button>Submit</button>
</form>
);
}
|