how navigate using the MenuItem? material-ui V1

和自甴很熟 提交于 2019-12-01 20:55:22

Heres what we found out...

You now need to use < NavLink > vs Link

React material-ui MenuItem containerElement not working

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>

You should use the component property. It is okay to use the Link component from react-router-dom:

<MenuItem component={Link} to="/logout">
  Logout
</MenuItem>

The containerElement attribute was used in v0.x and no longer exists as of v1.

Please refer to the docs for MenuItem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!