eduardoborges / use-mask-input

✏️ A react Hook for build elegant input masks. Compatible with React Hook Form
https://npmjs.com/package/use-mask-input
332 stars 19 forks source link

Integrate with react-hook-form `control` #59

Open hanza93 opened 1 year ago

hanza93 commented 1 year ago

We are using the controlled version for react-hook-form by using useControl hook. it would be awesome if we can use useHookFormMask with control too

alysonvilela commented 1 year ago

You can use it. Just re-subscribing ref value using withMask function

<Controller
  name="test"
  render={({ field }) => {
    return <input {...field} ref={withMask('9999-9999')}/>; // ✅
  }}
/>
eduardoborges commented 1 year ago

Hey @hanza93 im working on it, but for now you can use withMask like @alysonvilela demostrate above. <3

adrianwilk89 commented 1 year ago

@alysonvilela is problem with this solution because if you pass withMask as ref then primary functionality that scroll and focus element with errors stop working i mean if you set shouldFocusError to true