An open API service indexing awesome lists of open source software.

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`

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.