Skip to content

Commit

Permalink
Fix custom menu snippet in theming documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto authored and sdobz committed Feb 20, 2020
1 parent 291af03 commit 5e0797b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions docs/Theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ import React, { createElement } from 'react';
import { useSelector } from 'react-redux';
import { useMediaQuery } from '@material-ui/core';
import { MenuItemLink, getResources } from 'react-admin';
import { withRouter } from 'react-router-dom';
import DefaultIcon from '@material-ui/icons/ViewList';
import LabelIcon from '@material-ui/icons/Label';

const Menu = ({ onMenuClick, logout }) => {
Expand All @@ -732,8 +732,13 @@ const Menu = ({ onMenuClick, logout }) => {
<MenuItemLink
key={resource.name}
to={`/${resource.name}`}
primaryText={resource.options && resource.options.label || resource.name}
leftIcon={createElement(resource.icon)}
primaryText={
(resource.options && resource.options.label) ||
resource.name
}
leftIcon={
resource.icon ? <resource.icon /> : <DefaultIcon />
}
onClick={onMenuClick}
sidebarIsOpen={open}
/>
Expand All @@ -750,7 +755,7 @@ const Menu = ({ onMenuClick, logout }) => {
);
};

export default withRouter(Menu);
export default Menu;
```

**Tip**: Note the `MenuItemLink` component. It must be used to avoid unwanted side effects in mobile views.
Expand Down

0 comments on commit 5e0797b

Please sign in to comment.