I'm currently using react-bootstrap and react-imask together using their example with IMaskMixin:
import { IMaskMixin } from 'react-imask';
import { FormControl } from 'react-bootstrap';
const MaskedFormControl = IMaskMixin(({inputRef, ...props}) => (
<FormControl
{...props}
ref={inputRef}
/>
));
Now, I would like to use react-hook-form with this control;
const { register } = useForm();
<MaskedFormControl {...register('name')} />
The spread on the register function is the equivalent of this
const { onChange, onBlur, name, ref } = register('name');
So it is expecting the ref to access the input ref, the values in react-hook-form never get set with what is typed in the input.
I use MasedFormControl in places I dont' use react-hook-form so I would like to make it work with or without react-hook-form.
How do I make this work?
Not in particular for Bootstrap, but I'll show general idea on how to integrate react-imask, react-hook-form with any kind of input: