What is preventing MenuItemLink from being displayed in the menu?

I have created a unique page for users to purchase subscriptions, but I am having trouble accessing that page because the button is not appearing in the menu. I followed the steps outlined in the official guide, but only the dashboard and resources buttons are being rendered.

When I inspected the Menu, I noticed that it contains 3 children: 1 - Dashboard; 2 - Subscribe; 3 - Array of resource buttons.

P.S. I am using React-Admin v3.18.2. If you need more information, please leave a comment below.

Thank you.

menu.tsx

import React from 'react';
import { useSelector } from 'react-redux';
import { DashboardMenuItem, MenuItemLink, getResources, Menu, MenuProps } from 'react-admin';

import { CardMembership, ViewList } from '@material-ui/icons';



const CustomMenu = (props: MenuProps) => {
    const resources = useSelector(getResources);

    return (
        <Menu {...props}>
            <DashboardMenuItem />
            {/* @ts-ignore */}
            <MenuItemLink
                key="subscribe"
                to="/subscribe"
                primaryText="Subscriptions"
                leftIcon={<CardMembership/>}
            sidebarIsOpen={open}
            />
            {
                resources.map(resource => (
                    /* @ts-ignore */
                    <MenuItemLink
                        key={resource.name}
                        to={`/${resource.name}`}
                        primaryText={(resource.options && resource.options.label) || resource.name}
                        leftIcon={resource.icon ? <resource.icon /> : <ViewList />}
                        sidebarIsOpen={open}
                    />
                ))
            }
        </Menu>
    );
};

export default CustomMenu;

layout.tsx

import React from "react";
import { Layout, LayoutProps } from 'react-admin';

import CustomMenu from './menu';
import CustomAppBar from "./appBar";
import { ProfileProvider } from "../profile";



const CustomLayout = (props: LayoutProps) => (
    <ProfileProvider>
        <Layout {...props} appBar={CustomAppBar} menu={CustomMenu}/>
    </ProfileProvider>
);

export default CustomLayout;

App.tsx

import React from "react";
import dynamic from "next/dynamic";
import { Admin, Resource } from 'react-admin';
import { Work, Group, ViewList } from '@material-ui/icons';

import authProvider from './authProvider';
import dataProvider from './dataProvider';
import Dashboard from './dashboard';
import LoginPage from './login';
import CustomRoutes from './customRoutes';
import CustomLayout from './layouts/layout';
import { JobList, JobEdit, JobCreate } from './jobs';
import { AccountList, AccountEdit, AccountCreate } from './accounts';
import { ServiceList, ServiceEdit, ServiceCreate } from './services';



const App = () => (
    <Admin
        layout={CustomLayout}
        loginPage={LoginPage}
        dashboard={Dashboard}
        authProvider={authProvider}
        dataProvider={dataProvider}
        customRoutes={CustomRoutes}
    >
        {
            permissions => [
                permissions.subStatus === 'active'
                && <Resource
                    name="services"
                    list={ServiceList}
                    edit={ServiceEdit}
                    create={ServiceCreate}
                    icon={ViewList}
                    options={{ label: 'Services' }}
                />,

                permissions.subStatus === 'active'
                && <Resource
                    name="accounts"
                    list={AccountList}
                    edit={AccountEdit}
                    create={AccountCreate}
                    icon={Group}
                    options={{ label: 'Accounts' }}
                />,

                permissions.subStatus === 'active'
                && <Resource
                    name="jobs"
                    list={JobList}
                    edit={JobEdit}
                    create={JobCreate}
                    icon={Work}
                    options={{ label: 'Jobs' }}
                />,
            ]
        }
    </Admin>
);

const Run = dynamic(() => Promise.resolve(App), {
    ssr: false,
});

export default Run;

customRoutes.tsx

import React from "react";
import { Route } from 'react-router-dom';

import SubscribePage from './subscription';



const CustomRoutes = [
    <Route key="subscribe" exact path="/subscribe" component={SubscribePage}/>,
];

export default CustomRoutes;

UPDATE: I managed to solve the issue by updating react-admin to v3.19.7.

Answer №1

To create a route for a custom page, you will need to add the following code to your CustomRoutes file:

customRoutes.js:

import React from 'react'
import { Route } from 'react-router-dom'
import Subscribe from 'your_path_to/subscribe'

const CustomRoutes = [
  <Route exact path="/subscribe" render={() => <Subscribe /&>} />,
]
export default CustomRoutes

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Running Cypress/Next.js E2E tests with the --watch option proved to be successful, however, when attempting to run them in --head

Appreciation for the cypress team. Encountering an issue with e2e headless testing via command line. Test runs successfully with --watch option, but fails with --headless option. This needs to be resolved promptly as I intend to run it on CI. Commands ex ...

Identify when the Vue page changes and execute the appropriate function

Issue with Map Focus Within my application, there are two main tabs - Home and Map. The map functionality is implemented using OpenLayers. When navigating from the Home tab to the Map tab, a specific feature on the map should be focused on. However, if th ...

Passing a deconstructed object as a parameter for a function

I'm having trouble understanding the parameter const Posts in the code snippet below. As a newcomer to node/React, I'm not sure if it's a destructured parameter object or just an object being passed as a parameter. The functions getPosts an ...

Typescript's dynamic React component and its conditional types

I am currently working on a dynamic React component and I am facing an issue with properly passing the correct propType based on the selected component. The error arises when using <SelectComponent {...props.props} /> because the props do not match t ...

Tips on automating the process of moving overflowing elements into a dropdown menu

Challenge Description In need of a dynamic navigation bar, I faced the problem of displaying only the first X items on one line and have the remaining items hidden in a "Show more" dropdown. The challenge was to calculate the width of each item accurately ...

The specified class is not found in the type 'ILineOptions' for fabricjs

Attempting to incorporate the solution provided in this answer for typescript, , regarding creating a Line. The code snippet from the answer includes the following options: var line = new fabric.Line(points, { strokeWidth: 2, fill: '#999999', ...

What causes the Vercel deployment issue with my Next.js route?

I'm encountering an issue while trying to deploy my Next13 app on Vercel. The error message mentions something about a route not matching the required types of a Next.js Route. It also indicates that "prisma" is not a valid Route export field, leading ...

Tips for updating TypeScript aliases during compilation

To define a typescript alias in tsconfig.json, you can use the following syntax: "paths": { "@net/*":["net/*"], "@auth/*":["auth/*"], }, After defining the alias, you can then use it in you ...

What could be causing Nextjs13 to fail in recognizing an authentication route, resulting in a 404 error?

I have been working on a project utilizing NextJs v13 with Strapi v4 as the backend. My project includes separate layouts for the site, login, and dashboard. While working on the login section, I implemented NextAuth for authentication. However, upon submi ...

Encountering difficulties with installing npm packages from a cloned GitHub repository

I am interested in forking the React Data Grid repository on Github from here. My plan is to make some modifications and then integrate it into my react application. To prepare for this, I have included the name, version, and description attributes within ...

Error message "Could not locate module while constructing image in Docker."

I've encountered an issue while working on my nodeJS Typescript project. After successfully compiling the project locally, I attempted to create a docker image using commands like docker build or docker-compose up, but it failed with a 'Cannot fi ...

Error in Redux app: Attempting to access the 'filter' property of an undefined value

I am currently encountering an issue with my reducer: https://i.stack.imgur.com/7xiHJ.jpg Regarding the props actual, this represents the time of airplane departure or arrival, and it is a property within my API. The API structure looks like this: {"body ...

I attempted to use webpac-dev-server with the --hot option, but unfortunately, it is not functioning as

I am having trouble running the webpack-dev-server --hot command. When I try to run the webpack server, I encounter an error: C:\ReactJS>npm run it > [email protected] it C:\ReactJS > webpack-dev-server --hot C:\ReactJS&bsol ...

Getting started with editing and selecting a row using an onClick event in DataGrid

Currently working with MUI's DataGrid, I am looking to enable edit mode on a specific row and set focus to it. I am using the community edition of DataGrid, would this feature only be available in data-grid-x version? ...

When I tried to access my Next.js Full Stack Application deployed on Azure Web Apps, I encountered a 403 error message stating, "You do not have authorization to view this page or directory."

After developing a Full Stack application using Next.js with Typescript, I successfully deployed it to Azure Web Apps via GitHub. However, upon trying to access the website, an error message stating "You do not have permission to view this directory or pag ...

Angular 6: Harnessing the Power of RouterLinks

Can you navigate to a different section of another page using the defined ID without having to reload the entire page? ...

The onChange event does not work as expected for Select controls

I am facing an issue with my common useForm.tsx file when handling the onChange event for select controls. The error message I encounter is displayed below. Does anyone have any suggestions on how to resolve this? Error: Type '(e: ChangeEvent<HTM ...

Exploring the power of regular expressions in combination with React Router

Looking to create a route structure like mysite.com/hotel-newyork-123 in React using React Router. I've defined the regular expression as /.+-.+-\d/g. Now, I need help implementing this in a React app. Unfortunately, I haven't been able to f ...

An error was encountered in the index.js file within the app directory when running the webpack

Recently, I was told to learn react.js even though my knowledge of javascript is limited. Nevertheless, I decided to dive in and start with a simple "Hello World" project. Initially, when I used the index.js file below and ran webpack -p, everything worke ...

Is there a way to automatically update the state in ReactJS whenever new information is added or deleted, without the need to manually refresh the page

I have encountered an issue that I have been trying to resolve on my own without success. It seems that the problem lies in not updating the Lists New state after pushing or deleting from the API. How can I rectify this so that manual page refreshing is no ...