https://github.com/daxchen/material-ui-link-within-menuitem
Example for how to use `react-router/Link` within `material-ui/MenuItem`
https://github.com/daxchen/material-ui-link-within-menuitem
example-project material-ui react-router
Last synced: 2 months ago
JSON representation
Example for how to use `react-router/Link` within `material-ui/MenuItem`
- Host: GitHub
- URL: https://github.com/daxchen/material-ui-link-within-menuitem
- Owner: DaxChen
- Created: 2017-02-12T16:20:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-05T15:38:34.000Z (about 7 years ago)
- Last Synced: 2025-03-17T10:51:41.558Z (3 months ago)
- Topics: example-project, material-ui, react-router
- Language: HTML
- Homepage: https://daxchen.github.io/material-ui-Link-within-MenuItem
- Size: 3.56 MB
- Stars: 20
- Watchers: 2
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `react-router/Link` within `material-ui/MenuItem`
Example for how to use `react-router/Link` within `material-ui/MenuItem`> This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
## [Live Demo](https://daxchen.github.io/material-ui-Link-within-MenuItem)
## What is this?
This is an example app for [this
issue](https://github.com/callemall/material-ui/issues/204#issuecomment-269130245), which demonstrates using
react-router's `Link` within material-ui's `MenuItem` with the `containerElement` prop.```jsx
import { Link } from 'react-router'
import MenuItem from 'material-ui/MenuItem'}
primaryText="About Page"
/>
```For more information, see [the above issue](https://github.com/callemall/material-ui/issues/204), or [this
StackOverflow](http://stackoverflow.com/questions/32106513/material-ui-menu-using-routes).## FAQ
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 `/` 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.).## How to run
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.
Open [http://localhost:3000](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.### `npm run build`
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](#deployment) for more information.