Skip to content

Conversation

@erakli
Copy link

@erakli erakli commented Apr 17, 2022

Quick way to add custom menu items without Resource.

Usage:

import * as UI from 'ra-ui-materialui';
import TreeMenu from '@bb-tech/ra-treemenu';
import Settings from '@material-ui/icons/Settings';

const CustomMenuItems = [
  <UI.MenuItemLink
    to="/settings"
    primaryText="Settings"
    leftIcon={<Settings />}
  />,
];

const CustomLayout = (props) => {
  TreeMenu.defaultProps.customMenuItems = CustomMenuItems;
  return <UI.Layout {...props} menu={TreeMenu} />;
};

const App = (props) => (
  <Admin
    layout={(props) => <CustomLayout {...props} />}
    {...props}
  >
    {props.children}
  </Admin>
);

Better way is to support custom menu items inside menu but I didn't investigate this option because

  • there is RA v4 where CustomRoutes component exists
  • I don't know how to update the code of the lib for this

@erakli
Copy link
Author

erakli commented Apr 24, 2022

@ak-bigbasket Take a look please

@makivlach
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants