Runtime error with Checkbox and Material-UI v4
See original GitHub issueJust a heads-up. This may be due to changes in Material-UI v4 alpha.
The following:
<Field
Label={{ label: 'Do you confirm?" }}
name='confirmation'
component={CheckboxWithLabel}
color='primary'
/>
At runtime was causing:
Warning: Failed prop type: Invalid prop `checked` of type `string` supplied to `ForwardRef(Checkbox)`, expected `boolean`.
in ForwardRef(Checkbox) (created by WithStyles(ForwardRef(Checkbox)))
in WithStyles(ForwardRef(Checkbox)) (created by FormikMaterialUICheckboxWithLabel)
in label (created by ForwardRef(FormControlLabel))
in ForwardRef(FormControlLabel) (created by Context.Consumer)
in WithFormControlContext(ForwardRef(FormControlLabel)) (created by WithStyles(WithFormControlContext(ForwardRef(FormControlLabel))))
in WithStyles(WithFormControlContext(ForwardRef(FormControlLabel))) (created by FormikMaterialUICheckboxWithLabel)
Changing this:
To:
checked: field.value
That is, leaving the boolean value alone, not converting it to string, fixed it.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Upgrade from v3 to v4 - Error: Cannot find module #16468
Lets have a look into /node_modules/@material-ui/core/esm/Checkbox/Checkbox.js. The import causing this error is in line 6: import SwitchBase ...
Read more >my checkbox (material-ui) is not disabling - Stack Overflow
On the material ui docs page for checkbox components (https://material-ui.com/api/checkbox/#checkbox-api). It lists the disabled attribute ...
Read more >How to use Material UI Checkbox - Refine Dev
This article will deeply traverse the Material UI Checkbox component, investigate its processes and highlight its syntax application.
Read more >React Checkbox component - Material UI - MUI
Checkboxes allow the user to select one or more items from a set. Checkboxes can be used to turn an option on or...
Read more >androidx.compose.material - Android Developers
Represents the colors used by the three different sections (checkmark, box, and border) of a Checkbox or TriStateCheckbox in different states.
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 FreeTop 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
Top GitHub Comments
I think we should only merge the PR when 4 is released as we should bump the peer dependency 4.0 >=.
In the meantime you can use this:
I couldn’t find a PR so I went ahead an created it here: #75