react-hook-form / codemod

Migrate React Hook Form V6 to V7 made simple.
MIT License
26 stars 7 forks source link

Not working when name is template literal #11

Closed mister-gnommer closed 2 years ago

mister-gnommer commented 3 years ago

Describe the bug When there was template literal used in name of input codemod only removes ref={register} but doesn't create {...register()} and leaves name

To Reproduce example input before running codemod:

<input
name={`${key.name}.apply`}
type="checkbox"
ref={register}
label="should apply for this key?"
id={`${key.name}.apply`}
/>

After codemod:

<input
name={`${key.name}.apply`}
type="checkbox"

label="should apply for this key?"
id={`${key.name}.apply`}
/>

Expected behavior

<input
{...register(`${key.name}.apply`)}
type="checkbox"
label="should apply for this key?"
id={`${key.name}.apply`}
/>
jorisre commented 2 years ago

Thanks for reporting. I'll look at it next week

jorisre commented 2 years ago

Time flies! Here is the fix https://github.com/react-hook-form/codemod/pull/12 Feel free to review ✌🏻