-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Failed prop type: Invalid prop children
of type array
supplied to ForwardRef(ListItemIcon)
, expected a single ReactElement.
#15911
Comments
It looks like you're passing a |
My code |
Removing white space around the
|
i just have the same error, wrapping all inside a fragment (</>) resolved:
|
@iagokrt Looking at the source of ListItemIcon.js, this constraint is no longer required, it seems that we can loosen it. Do you want to submit a pull request? :) diff --git a/packages/material-ui/src/ListItemIcon/ListItemIcon.d.ts b/packages/material-ui/src/ListItemIcon/ListItemIcon.d.ts
index 029ca35a3..16fb588e5 100644
--- a/packages/material-ui/src/ListItemIcon/ListItemIcon.d.ts
+++ b/packages/material-ui/src/ListItemIcon/ListItemIcon.d.ts
@@ -6,7 +6,7 @@ export interface ListItemIconProps
* The content of the component, normally `Icon`, `SvgIcon`,
* or a `@material-ui/icons` SVG icon element.
*/
- children: React.ReactElement;
+ children: React.ReactNode;
}
export type ListItemIconClassKey = 'root'; |
@oliviertassinari Hi, I'm creating a pull request for this, but somehow changing the definition to Sorry, but what am I missing here? and how was it marked required before when it was |
Don't worry about. ReactNode includes undefined which is why it isn't marked as required anymore. |
So we are referring to this case: What about children?: React.ReactNode; instead? |
So is it ok to change the prop |
@ask2mahtab I think so, it would match with #20458. |
In my case, I was passing a boolean value to my Modal component whereas it was undefined so, it made children component invalid |
Failed prop type: Invalid prop

children
of typearray
supplied toForwardRef(ListItemIcon)
, expected a single ReactElement.<ListItem style={{"marginTop":"-16px","marginBottom": "-7px"}} button key={i+"i"} >
<ListItemIcon key={i+ subOption.text+'d' } className={classes.menuPosition}><span key={ subOption.text+1+i+1 } className={subOption.icon}/>
<ListItemText style={{marginBottom:'-5px',marginTop:'-8px', padding:'0px 16px'}} key={i+ subOption.text+'e'} primary={ subOption.text }
className="menu-text-Color"
/>
The text was updated successfully, but these errors were encountered: