1

I have following code:

<MenuItem primaryText="home" containerElement={<Link to="/" />} />

But it doesn't work as explained in other topics/threads where MenuItem discussed like here Material UI Menu using routes. Once i add containerElement prop to MenuItem i'm getting this exception:

Uncaught Error: 
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. 
You likely forgot to export your component from the file it's defined in.
Check the render method of `EnhancedButton`.
Community
  • 1
  • 1
comprex
  • 743
  • 3
  • 9
  • 20

1 Answers1

3

It looks like that no longer works (will need to find the change log.)

To fix this I did npm install react-router-dom --save and used the following snippet:

import React, { Component } from 'react';
import { NavLink } from 'react-router-dom'
import Menu from 'material-ui/Menu';
import MenuItem from 'material-ui/MenuItem';
import Drawer from 'material-ui/Drawer'

    <Drawer
         docked={false}
         open={this.state.open}
         onRequestChange={(open) => this.setState({open})}>
         <MenuItem onTouchTap={() => {this.handleClose()}} >
              <NavLink to="/">Home </NavLink>
         </MenuItem>
         <MenuItem onTouchTap={() => {this.handleClose() }} >
              <NavLink to="/about"> About Us </NavLink>
         </MenuItem>
    </Drawer>