@@ -248,20 +248,26 @@ The content of the user menu depends on the return value of `authProvider.getIde
248248
249249You can customize the user menu by passing a ` userMenu ` prop to the ` <AppBar> ` component.
250250
251- ``` jsx
251+ ``` tsx
252252import * as React from ' react' ;
253- import { AppBar , UserMenu , useUserMenu } from ' react-admin' ;
253+ import { AppBar , Logout , UserMenu , useUserMenu } from ' react-admin' ;
254254import { MenuItem , ListItemIcon , ListItemText } from ' @mui/material' ;
255255import SettingsIcon from ' @mui/icons-material/Settings' ;
256+ import { Link } from " react-router-dom" ;
256257
257258// It's important to pass the ref to allow Material UI to manage the keyboard navigation
258- const SettingsMenuItem = React .forwardRef ((props , ref ) => {
259- // We are not using MenuItemLink so we retrieve the onClose function from the UserContext
260- const { onClose } = useUserMenu ();
259+ const SettingsMenuItem = React .forwardRef <HTMLAnchorElement >((props , ref ) => {
260+ const userMenuContext = useUserMenu ();
261+ if (! userMenuContext ) {
262+ throw new Error (" <SettingsMenuItem> should be used inside a <UserMenu>" );
263+ }
264+ const { onClose } = userMenuContext ;
261265 return (
262266 <MenuItem
263267 onClick = { onClose }
264268 ref = { ref }
269+ component = { Link }
270+ to = " /settings"
265271 // It's important to pass the props to allow Material UI to manage the keyboard navigation
266272 { ... props }
267273 >
@@ -273,7 +279,7 @@ const SettingsMenuItem = React.forwardRef((props, ref) => {
273279 );
274280});
275281
276- const MyAppBar = () => (
282+ export const MyAppBar = () => (
277283 <AppBar
278284 userMenu = {
279285 <UserMenu >
0 commit comments