[@mantine/core] RadioGroup not compatible with React Hook Form
See original GitHub issueMantine’s RadioGroup (and likely other form elements) are not compatible with React Hook Form, a popular forms library.
Repro is here, where I try to register the RadioGroup input with the form: https://codesandbox.io/s/frosty-vaughan-0j0xb
Specifically it seems like the onChange
parameter has a different type in Mantine and react-hook-form:
Type '{ children: Element[]; onChange: ChangeHandler; onBlur: ChangeHandler; ref: RefCallBack; name: string; }' is not assignable to type 'RadioGroupProps'.
Types of property 'onChange' are incompatible.
Type 'ChangeHandler' is not assignable to type '(value: string) => void'.
Types of parameters 'event' and 'value' are incompatible.
Type 'string' is not assignable to type '{ target: any; type?: any; }'.ts(2322)
Package versions:
"dependencies": {
"@mantine/core": "3.2.2",
"@mantine/hooks": "3.2.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "7.20.2",
"react-scripts": "4.0.3"
},
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Trouble creating radio buttons inside a controller, the value I ...
Trouble creating radio buttons inside a controller, the value I want simply disappear from the form.
Read more >Radio buttons with react-hook-form - Stack Overflow
I created a form with react-hook-form. It logs "fullName" and "city" correctly in the console, but not the radio buttons.
Read more >Version 4.0.0 - Mantine
React components and hooks library with native dark theme support and focus on usability, accessibility and developer experience.
Read more >React Hook Form 7 Custom Radio Buttons Tutorial - positronX.io
We'll answer how to build the radio buttons component in React with React Hook Form and Yup packages, including radio buttons validation.
Read more >@mantine/labs: Versions | Openbase
defaultRadius not being respected; [@mantine/core] Select: Fix theme.defaultRadius not being ... [@mantine/core] Rating: Fix broken react 17 compatibility.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://codesandbox.io/s/frosty-mahavira-jexit?file=/src/App.tsx
Thanks for the help over Discord, @getTobiasNielsen
I’ll use this controller method for now, and look into getting a PR in at RHF to use the
getControllerValue
helper in register’s onChange implementation in the next week or two.