Download react-hook-form/examples/V6/forwardRefToPassRefProp.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 518 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/examples/V6/forwardRefToPassRefProp.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/examples/V6/forwardRefToPassRefProp.tsx
-
curl -L -o forwardRefToPassRefProp.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/examples/V6/forwardRefToPassRefProp.tsx
518 Bytes
| 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> | |
| ); | |
| } | |