> For the complete documentation index, see [llms.txt](https://phoenixcoded.gitbook.io/able-pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://phoenixcoded.gitbook.io/able-pro/nextjs/how-to/remove-menu-render-from-backend.md).

# Remove menu render from Backend

{% tabs %}
{% tab title="NEXT (TS)" %}
In the Able Pro React admin, a few **dashboard menus (i.e. Default, Analytics, Components)** load from our mock API ([GitHub repository](https://github.com/phoenixcoded20/mock-data-api-nextjs)). If you want to remove it from your admin panel, follow the steps below and remove/edit the suggested line of code.

1. **Delete the menu-items file** `dashboard.tsx` \[`src/menu-items/dashboard.jsx`]
2. **Open file** `src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.tsx` **and edit the line of code.**

**From:**

{% code title="src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.tsx" %}

```typescript
import { Fragment, useLayoutEffect, useState } from 'react';
...
import menuItem from 'menu-items';
import { useGetMenu, useGetMenuMaster } from 'api/menu';
```

{% endcode %}

**To:**

{% code title="src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.tsx" %}

```typescript
import { Fragment, useState } from 'react';
...
import menuItems from 'menu-items';
import { useGetMenuMaster } from 'api/menu';
```

{% endcode %}

3. **Open file** `src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.tsx` **and remove the line of code.**

{% code title="src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.tsx" %}

```typescript
import { MenuFromAPI } from 'menu-items/dashboard';

function isFound(arr: any, str: string) {
  return arr.items.some((element: any) => {
	if (element.id === str) {
	  return true;
	}
	return false;
  });
}
	
export default function Navigation() {
	...		
	const { menuLoading } = useGetMenu();		
	...		
	const [menuItems, setMenuItems] = useState<{ items: NavItemType[] }>({ items: [] });

	let dashboardMenu = MenuFromAPI();

	useLayoutEffect(() => {
		if (menuLoading && !isFound(menuItem, 'group-dashboard-loading')) {
		  menuItem.items.splice(0, 0, dashboardMenu);
		  setMenuItems({ items: [...menuItem.items] });
		} else if (!menuLoading && dashboardMenu?.id !== undefined && !isFound(menuItem, 'group-dashboard')) {
		  menuItem.items.splice(0, 1, dashboardMenu);
		  setMenuItems({ items: [...menuItem.items] });
		} else {
		  setMenuItems({ items: [...menuItem.items] });
		}
	// eslint-disable-next-line
	}, [menuLoading]);
}
```

{% endcode %}

4. **Open file** `src\api\menu.ts` **and edit the line of code.**

**From:**

{% code title="src/api/menu.ts" %}

```typescript
import { MenuProps, NavItemType } from 'types/menu';
```

{% endcode %}

**To:**

{% code title="src/api/menu.ts" %}

```typescript
import { MenuProps } from 'types/menu';
```

{% endcode %}

5. **Open the file** `src\api\menu.ts` **and remove the code below.**

{% code title="src/api/menu.ts" %}

```typescript
import { fetcher } from 'utils/axios';
	
export const endpoints = {
  ...
  dashboard: '/dashboard' // server URL
};
	
export function useGetMenu() {
  const { data, isLoading, error, isValidating } = useSWR(endpoints.key + endpoints.dashboard, fetcher, {
	revalidateIfStale: false,
	revalidateOnFocus: false,
	revalidateOnReconnect: false
  });

  const memoizedValue = useMemo(
	() => ({
	  menu: data?.dashboard as NavItemType,
	  menuLoading: isLoading,
	  menuError: error,
	  menuValidating: isValidating,
	  menuEmpty: !isLoading && !data?.length
	}),
	[data, error, isLoading, isValidating]
  );

  return memoizedValue;
}
```

{% endcode %}
{% endtab %}

{% tab title="NEXT (JS)" %}
In the Able Pro React admin, a few **dashboard menus (i.e. Default, Analytics, Components)** load from our mock API ([GitHub repository](https://github.com/phoenixcoded20/mock-data-api-nextjs)). If you want to remove it from your admin panel, follow the steps below and remove/edit the suggested line of code.

1. **Delete menu-items file** `dashboard.jsx` \[`src/menu-items/dashboard.jsx`]
2. **Open file** `src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.jsx` **and edit the below line of code.**

**From:**

{% code title="src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.jsx" %}

```javascript
import { Fragment, useLayoutEffect, useState } from 'react';
...
import menuItem from 'menu-items';
import { useGetMenu, useGetMenuMaster } from 'api/menu';
```

{% endcode %}

**To:**

{% code title="src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.jsx" %}

```javascript
import { Fragment, useState } from 'react';
...
import menuItems from 'menu-items';
import { useGetMenuMaster } from 'api/menu';
```

{% endcode %}

3. **Open file** `src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.jsx` **and remove the below line of code.**

{% code title="src/layout/DashboardLayout/Drawer/DrawerContent/Navigation/index.jsx" %}

```javascript
import { MenuFromAPI } from 'menu-items/dashboard';

function isFound(arr, str) {
  return arr.items.some((element) => {
    if (element.id === str) {
      return true;
    }
    return false;
  });
}
	
export default function Navigation() {
	...		
	const { menuLoading } = useGetMenu();		
	...		
	const [menuItems, setMenuItems] = useState({ items: [] });

	const dashboardMenu = MenuFromAPI();

	useLayoutEffect(() => {
		if (menuLoading && !isFound(menuItem, 'group-dashboard-loading')) {
		  menuItem.items.splice(0, 0, dashboardMenu);
		  setMenuItems({ items: [...menuItem.items] });
		} else if (!menuLoading && dashboardMenu?.id !== undefined && !isFound(menuItem, 'group-dashboard')) {
		  menuItem.items.splice(0, 1, dashboardMenu);
		  setMenuItems({ items: [...menuItem.items] });
		} else {
		  setMenuItems({ items: [...menuItem.items] });
		}
	// eslint-disable-next-line
	}, [menuLoading]);
}
```

{% endcode %}

4. **Open the file** `src\api\menu.js` **and remove the code below.**

{% code title="src/api/menu.js" %}

```javascript
import { fetcher } from 'utils/axios';
	
export const endpoints = {
  ...
  dashboard: '/dashboard' // server URL
};
	
export function useGetMenu() {
  const { data, isLoading, error, isValidating } = useSWR(endpoints.key + endpoints.dashboard, fetcher, {
	revalidateIfStale: false,
	revalidateOnFocus: false,
	revalidateOnReconnect: false
  });

  const memoizedValue = useMemo(
	() => ({
	  menu: data?.dashboard,
	  menuLoading: isLoading,
	  menuError: error,
	  menuValidating: isValidating,
	  menuEmpty: !isLoading && !data?.length
	}),
	[data, error, isLoading, isValidating]
  );

  return memoizedValue;
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
