I'm using Material-UI
in my project, I'm getting a warning in the console:
Warning: validateDOMNesting(...): <button> cannot appear as a descendant of <button>
even though there are no direct descendants,
<form>
<TextField
label="Title"
value={title}
onChange={this.handleChange("title")}
className={classes.formControl}
margin="normal"
/>
<br />
<FormControl className={classes.formControl}>
<InputLabel>Muscles</InputLabel>
<Select
value={muscles}
onChange={this.handleChange("muscles")}
>
{categories.map((category, index) => {
return (
<MenuItem key="index" value={category}>
{category}
</MenuItem>
);
})}
</Select>
</FormControl>
<br />
<TextField
multiline
rows={4}
label="Description"
value={description}
onChange={this.handleChange("description")}
className={classes.formControl}
margin="normal"
/>
</form>
Here's the Sandbox link:
https://codesandbox.io/s/react-material-ui-0yqeo
The default elementType
for the Fab
component is button. In your App the Fab
component is already nested in a Button
component hence the error. The Fab
component inherits from ButtonBase
so you should be able to remove the top level Button
component and use onClick
directly on it:
<Fab
color="secondary"
aria-label="add"
size="small"
onClick={this.handleToggle}
>
<AddIcon />
</Fab>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With