React Hook Form Integration #823
Replies: 4 comments 4 replies
-
Hey @vnguyen94! Forwarding this discussion along to eng - we'll be in touch soon! |
Beta Was this translation helpful? Give feedback.
-
Hi @vnguyen94, It's my first time hearing about React Hook Form and I really like it so far! So I did some digging into the library and short answer: I think using the supplied Controller is the correct path forward. Slightly longer answer: I was shocked that CheckboxGroup worked but RadioGroup did not, so I did some digging. RadioGroup uses context but CheckboxGroup maps over children and clones them with additional props passed through. I think that CheckboxGroup has to be updated to using context too, so that component may need a controller as well. Initially, RadioGroup did the children mapping too, until this issue was reported. As you can understand, I don't think there's a clean way to provide the Group functionality with override-able props if we map children rather than use React context. These Group components are necessary to Paste because it makes downstream style updates easier to manage in the future. If you have any additional thoughts or suggestions please report back! This is really nice work here! Thanks for bringing all this to our attention! |
Beta Was this translation helpful? Give feedback.
-
@vnguyen94 The CheckboxGroup changes are in a PR and will probably land today (#858). Just an FYI 👍 |
Beta Was this translation helpful? Give feedback.
-
Hi @vnguyen94 we just merged #1251. Once everything builds you should be able to use the various form components without needing to add |
Beta Was this translation helpful? Give feedback.
-
Code Sandbox: https://codesandbox.io/s/paste-starter-kit-with-react-hook-form-ibd8e?file=/src/Form.tsx
Hi team,
I played around with integrating the form library React Hook Form with Paste and I had pretty satisfying results. Because Paste lightly wraps and correct passes refs forward, it was pretty easy to integrate the two (versus having to create declarative bindings for formik). I did have to add a little code to integrate RadioGroup since it relies on React Context, see code snippet below (truncated from the sandbox):
I guess my ask is more of, what are your thoughts on this integration? Do you feel like there's a way to decouple context from the RadioGroup, or if using React Hook Form's supplied Controller component to accomplish this is fine as is?
Beta Was this translation helpful? Give feedback.
All reactions