question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[@mantine/core] RadioGroup not compatible with React Hook Form

See original GitHub issue

Mantine’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:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
LucasLemanowiczcommented, Nov 25, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found