New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with react-hook-form library #3658
Comments
Yep, I've just run into this same issue. Luckily it appears that react-hook-from has a Controller wrapper that claims to address this for arbitrary UI libraries, and you don't use the register function at all: Here's a modified version of your codesandbox that shows react-hook-form Controller working with Grommet's TextInput and Select. I'm still working on tweaking the configuration of both the Controller and the grommet inputs to avoid the "A component is changing an uncontrolled input of type text to be controlled" warning. For now, at least it doesn't crash. EDIT: looks like adding |
I am also very interested in using with react-hook-form. |
@pedrosimao Can you share inputs of what are the reasons you'd like to use react-hook-form on top of Grommet Form, I'm trying to see if there are any gaps we can bridge so users wouldn't need an additional dependency. |
@ShimiSun |
What I would suggest is to add a |
I think that is the right direction to head, ensuring |
@ericsoderberghp good! Do you think it would be a lot of work? I could definitely contribute to this. I just don't know what kind of approval we may need from the Grommet core team. |
I would recommend trying it out with one component, like TextInput, filing a PR with that for feedback, and proceeding from there. |
Thanks for advice. TextInput seems to have defaultValue already, even though if not documented. |
I am working on a package for Use React Hook Form with Grommet http://npmjs.com/package/grommet-hook-form |
Has anyone been able to find a work around for setting the default value on a Grommet Select component while using react-hook-form? I've tried the Controller, but that's not working for me either. |
Any updates on this by any chance? I am building an app with lots of long forms. This can be really helpful. I went through Formik integration documentation but react-hook-form looks simpler. Thanks! |
I know is not a bug, but I'm trying to use grommet with the react-hook-form library instead of formik. The react-hook-form is increasing its popularity and I think is a good way to manage forms in term of code quality and performance, but grommet seems to not be totally compatible with it.
Anyone tried react-hook-form with grommet? Any suggestion? I'm trying to use the
Select
component and theforwardRef
prop to pass theregister
function (as needed by react-hook-form), but when I click on the select on browser everything crash, causing a blank page.Here a codesandbox: https://codesandbox.io/s/grommet-select-not-working-with-react-hook-form-5rjsb
If you click twice on the second Select everything will crash.
The text was updated successfully, but these errors were encountered: