Skip to content
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

New Components Menu and MenuItem doesn't work #1236

Closed
eyscode opened this issue Jul 21, 2015 · 16 comments
Closed

New Components Menu and MenuItem doesn't work #1236

eyscode opened this issue Jul 21, 2015 · 16 comments
Labels
component: menu This is the name of the generic UI component, not the React module!

Comments

@eyscode
Copy link

eyscode commented Jul 21, 2015

I've tried to use the new components Menu and MenuItem in a project as the website shows but I couldn't, when the component is rendered the menu is not visible and width is always 0, I thought it was a problem with styles of my project, so I tried to use it in clean tiny example just for seeing if it works or not, and sadly it doesn't.

This is the code:

var React = require('react');
var Menu = require('material-ui/lib/menus/menu');
var MenuItem = require('material-ui/lib/menus/menu-item');
var ThemeManager =  require('material-ui/lib/styles').ThemeManager;
var themeManager = new ThemeManager();

var styles = {
    menu: {
        marginRight: 32,
        marginBottom: 32,
        float: 'left',
        position: 'relative',
        zIndex: 0
    }
};

var App = React.createClass({
    contextTypes: {
        router:React.PropTypes.func
    },
    childContextTypes: {
        muiTheme:React.PropTypes.object
    },
    getChildContext:function() {
        return {
                muiTheme: themeManager.getCurrentTheme()
        };
    },
    render: function(){
    return (
        <Menu style={styles.menu}>
          <MenuItem primaryText="Maps" />
          <MenuItem primaryText="Books" />
          <MenuItem primaryText="Flights" />
          <MenuItem primaryText="Apps" />
        </Menu>);
    }

});

React.render(<App/>, document.getElementById('app'));

As you can see it is the almost the same code as the example in the website demo, but the menu is not visible. What's the problem? Are the new Menu and MenuItem components already finished and ready for production? Thanks in advance.

@inoc603
Copy link

inoc603 commented Jul 22, 2015

I'm getting the same problem here. The component is rendered but not visible

@vespakoen
Copy link

👍 Same is happening here

@micaste
Copy link
Contributor

micaste commented Jul 22, 2015

👍

@zachguo
Copy link
Contributor

zachguo commented Jul 22, 2015

Same for ListItem, the component is rendered but not visible.

@zachguo
Copy link
Contributor

zachguo commented Jul 22, 2015

Well, it's working after I upgraded material-ui to latest version.

@micaste
Copy link
Contributor

micaste commented Jul 23, 2015

@zachguo what last version do you talk about ? I encounter the bug mentioned by @eyscode with version 0.10.1 that is for now the latest released version.

@eyscode
Copy link
Author

eyscode commented Jul 23, 2015

@zachguo List and ListItem works fine in the latest version, I've even had to use those component instead of Menu and MenuItem because the bug.

@ieiayaobb
Copy link

I've got a log in the console:
Uncaught TypeError: Cannot read property 'length' of undefined
it points to this line of the source file(menu.js)
for (var i = 0; i < this.props.menuItems.length; i++) {

@eyscode
Copy link
Author

eyscode commented Jul 24, 2015

It seems like you are using the old Menu and MenuItem components, I saw the same error log when I imported those components by mistake.

Old components:

import {Menu, MenuItem} from 'material-ui';

New components:

import Menu from 'material-ui/lib/menus/menu';
import MenuItem from 'material-ui/lib/menus/menu-item';

Anyway the new ones don't work properly, so I suggest using List and ListItem for now.

@ieiayaobb
Copy link

@eyscode
I tried as you said, same problem with you have described.
I'm going to use List instead.

Anyway thanks for your advice.

@eyscode
Copy link
Author

eyscode commented Aug 14, 2015

I've updated to the latest version of material-ui (v0.10.3) and the new Menu component works fine now. It seems like the bug was fixed in #1281. I'm closing the issue, thanks for your time.

@eyscode eyscode closed this as completed Aug 14, 2015
@cvince
Copy link

cvince commented Oct 16, 2015

this is still a problem. When you

import {Menu, MenuItem} from 'material-ui'; 

it's still referencing the old material-ui/lib/menu/menu.js

@austinmao
Copy link

I am still seeing this problem with the latest Master branch build.

This results in a length undefined error

import {Menu, MenuItem, MenuDivider} from 'material-ui';

This results in an invisible menu:

import Menu from 'material-ui-updated/lib/menus/menu';
import MenuItem from 'material-ui-updated/lib/menus/menu-item';

@AtNovember
Copy link

Dear developers!
Please, update your documentation!

`Cuz i had the same stack

@ingridoberbuchler
Copy link

Is there solution, please? I have same problem.

@ivanberry
Copy link

Problem still, Any solution?

mnajdova pushed a commit to mnajdova/material-ui that referenced this issue Nov 10, 2020
mnajdova pushed a commit to mnajdova/material-ui that referenced this issue Nov 10, 2020
After mui#1236, a few imports were remaining, remove those imports.
Also use type `Omit` from typescript utility types. This will ensure
zero direct references to `@material-ui/core`.
@zannager zannager added the component: menu This is the name of the generic UI component, not the React module! label Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests