Example for how to use react-router/Link
within material-ui/MenuItem
This project was bootstrapped with Create React App.
This is an example app for this
issue, which demonstrates using
react-router's Link
within material-ui's MenuItem
with the containerElement
prop.
import { Link } from 'react-router'
import MenuItem from 'material-ui/MenuItem'
<MenuItem
containerElement={<Link to="/about" />}
primaryText="About Page"
/>
For more information, see the above issue, or this StackOverflow.
Why not `href`?
Using href
instead of react-router's Link
component will cause the page to reload
Why not `onTouchTap` and programmically change route?
Using onTouchTap/onClick
to trigger page change instead of <a>/<Link />
will lose some native features such as
the link previewing in browser status bar, and the ability for users to open link in a new tab (mousewheel-click
, cmd + click
on macOS, ctrl + click
on windows, click and hold
on mobile devices, etc.).
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.