Using a Custom Input Component with RHF #1723
-
Hey, thanks in advance for all of your help and for an awesome library. https://codesandbox.io/s/compassionate-firefly-cmjus?file=/src/App.js I have what I imagine is a pretty standard situation. I am trying to rewrite a basic react form using the useState hook to use RHF. We have a custom component in this form that is a bit of a blackbox, It is very complex and not something in scope to rewrite. It is a table where you can modify multiple values at once and get an array in return. Luckily it has a very simple API where you just give it the value and the setValue functions from the useState hook and it handles the rest. I didn't see any documentation for this scenario and I fiddled a bunch with using getValues/setValues and watch in some combination but I figured I would go to the source for their recommendations! Please let me know if I can clarify anything. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hey @lexszentmiklosy i would use Controller for any of the custom components, as long as the component does expose Take a look at this example: https://github.com/react-hook-form/react-hook-form/blob/master/examples/parseFormatInputValues.tsx |
Beta Was this translation helpful? Give feedback.
-
Hi I have a question about these properties: Warning: Unknown event handler property Warning: React does not recognize the I know it's only a warning, but is there something I can do about this? Thanks Jovana. |
Beta Was this translation helpful? Give feedback.
Hey @lexszentmiklosy i would use Controller for any of the custom components, as long as the component does expose
onChange
andvalue
.Take a look at this example: https://github.com/react-hook-form/react-hook-form/blob/master/examples/parseFormatInputValues.tsx