-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Hidden MenuItem in MenuList causes props warning #12468
Comments
Using the render prop API would solve this issue. Right now, the workaround is to use an intermediary component to forward the properties |
I'm not sure I understand what you mean. Do you mean pass it to MenuList as a render prop? Could I trouble you for a simple example of what you mean? Since it's just a warning it's not the end of the world, but if there's a work-around I would love to use it to cut down on the noise in my console. |
@jkrehm I hope that help: import React from "react";
import Hidden from "@material-ui/core/Hidden";
import MenuList from "@material-ui/core/MenuList";
import MenuItem from "@material-ui/core/MenuItem";
// Exposes the injected properties.
const Wire = ({ children, ...props }) => children(props);
const Menu = () => (
// MenuList is using React.cloneElement for all it's children.
<MenuList role="menu">
<Wire>
{props => (
<Hidden smUp>
<MenuItem {...props} onClick={() => {}}>
Menu Item
</MenuItem>
</Hidden>
)}
</Wire>
<MenuItem onClick={() => {}}>Menu Item</MenuItem>
</MenuList>
);
export default Menu; |
Anyway, I think that we can remove the internal |
Thank you for that example. It's very helpful. Also, if the internal API can change so this work-around isn't needed, even better. |
|
When a MenuList has a MenuItem wrapped by Hidden, a warning is generated.
I believe MenuList sets those properties, so even if I wanted to not set them they would get set.
A few issues are similar, but not exactly this issue: #12302 #12159 #11467.
Expected Behavior
The MenuItem should display on the correct screen resolution without producing warnings.
Current Behavior
The MenuItem produces warnings.
Steps to Reproduce
Link: https://codesandbox.io/s/y2vnzl1m8v
For example:
Context
I want some menu items to display on small screen sizes. On large screen sizes they will appear as buttons outside the menu.
Your Environment
The text was updated successfully, but these errors were encountered: