![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@hookform/codemod
Advanced tools
<img src="https://raw.githubusercontent.com/bluebill1049/react-hook-form/master/docs/logo.png" a
Performant, flexible and extensible forms with easy to use validation.
Migrate your React Hook Form codebase from older version to new without the hassle by using our codemod scripts
npx @hookform/codemod <transform> <path> [...options]
transform
- name of transform, see available transforms below.path
- files or directory to transform--dry
option for a dry-run and use --print
to print the output for comparisonThis will start an interactive wizard, and then run the specified transform.
v7/update-register
Update the register
API inside a component that use useForm
of React Hook Form. This transform is not applied if the component doesn't use useForm
.
npx @hookform/codemod v7/update-register
- <input ref={register} name="example" />
+ <input {...register('example')} />
- <input ref={register()} name="example" />
+ <input {...register('example')} />
- <input ref={register()} name="example" />
+ <input {...register('example')} />
- <input ref={register({ required: true })} name="example" />
+ <input {...register('example', { required: true })} />
- <TextInput ref={register({ required: true })} name="example" />
+ <TextInput {...register('example', { required: true })} />
With a custom register
name
function MyForm() {
const { register: customRegister } = useForm();
return (
<form>
- <input ref={customRegister} name="example" />
+ <input {...customRegister('example')} />
</form>
);
}
v7/move-errors-to-formState
It moves errors
API into formState
inside a component that use useForm
of React Hook Form. This transform is not applied if the component doesn't use useForm
.
npx @hookform/codemod v7/move-errors-to-formState
- const { errors } = useForm();
+ const { formState: { errors } } = useForm();
- const { errors: customErrors } = useForm();
+ const { formState: { errors: customErrors } } = useForm();
- const { errors, formState: { isDirty } } = useForm();
+ const { formState: { isDirty, errors } } = useForm();
- const { errors: customErrors, formState: { isDirty } } = useForm();
+ const { formState: { isDirty, errors: customErrors } } = useForm();
With a custom register
name
function MyForm() {
- const { errors, formState } = useForm();
+ const { formState } = useForm();
+ const { errors } = formState;
const isDirty = formState.isDirty;
return (
//
);
}
Thanks goes to all our backers! [Become a backer].
Thanks goes to these wonderful organizations! [Contribute].
Thanks goes to these wonderful people! [Become a contributor].
FAQs
<img src="https://raw.githubusercontent.com/bluebill1049/react-hook-form/master/docs/logo.png" a
The npm package @hookform/codemod receives a total of 201 weekly downloads. As such, @hookform/codemod popularity was classified as not popular.
We found that @hookform/codemod demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.