Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After updating umi from ^3.5.23 to ^4.3.28 menu is not rendering. #12822

Open
IndhuKandhaiya opened this issue Dec 4, 2024 · 1 comment
Open

Comments

@IndhuKandhaiya
Copy link

What happens?

After updating umi from ^3.5.23 to ^4.3.28, react from ^16.14.0 to 18.2.0 and antd from ^5.2.3 to ^5.21.5, and also @ant-design/pro-components: ^2.8.1, @ant-design/pro-layout: ^7.4.0 menu is not rendering in sideBar.

Mini Showcase

routes.ts

const routes = [
  {
    path: '/',
    name: 'home',
    component: '../layouts/LoginRequiredLayout',
    routes: [
      {
        path: '/',
        name: 'home',
        component: '../layouts/MembershipRequiredLayout',
        routes: [
          {
            path: '/',
            name: 'home',
            component: '../layouts/BasicLayout',
            authority: ['user'],
            routes: [
              {
                path: '/',
                redirect: '/dashboard',
              },
              {
                path: '/dashboard',
                name: 'home',
                icon: 'home',
                component: './dashboard/dashboard-settings/DashboardSettings',
              },
            ],
          },
        ],
      },
    ],
  },
];

export default routes;

config.ts

const config: IConfig = defineConfig({
  ...(MFSU_ENABLED
    ? {
        mfsu: false,
      }
    : {}),
  plugins: [
    '@umijs/plugins/dist/antd',
    '@umijs/plugins/dist/dva',
    '@umijs/plugins/dist/locale',
    '@umijs/plugins/dist/request',
  ],
  request: {},
  antd: {},
  dva: {
    immer: {},
    hmr: true,
  },
  locale: {
    antd: true,
    default: 'en-US',
    baseNavigator: false,
  },
  hash: true,
  routes: routes,

 
  ignoreMomentLocale: true,
  copy: [],
  lessLoader: {
    javascriptEnabled: true,
  },
  manifest: {
    basePath: '/',
  },
});

export default config;

BasicLayout

const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
  const {
    dispatch,
    settings,
    location = { pathname: '/' },
    user: currentUser,
    lock: { isLockdownScreen } = { isLockdownScreen: false },
  } = props;
  
  const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] => {
    return menuList.map((item) => {
      const localItem = {
        ...item,
        children: item.children ? menuDataRender(item.children) : [],
      };

      return Authorized.check(item.authority, localItem, null) as MenuDataItem;
    });
  };

  const renderMenuItem = (menuItemProps, defaultDom, numberOfFlags) => {
    if (menuItemProps.isUrl) {
      return defaultDom;
    }

    const menuItem = <Link to={menuItemProps?.path}>{defaultDom}</Link>;

    return menuItem;
  };

  return (
      <ProLayout
        logo={logoIcon}
        className={styles.basicOverrides}
        menuHeaderRender={(logoDom, titleDom) => (
          <>
            {logo}
          </>
        )}
        onCollapse={handleMenuCollapse}
        menuItemRender={(
          menuItemProps: MenuDataItem,
          defaultDom: React.ReactNode,
        ): React.ReactNode => renderMenuItem(menuItemProps, defaultDom, numberOfFlags)}
        breadcrumbRender={(
          routers: { path: string; breadcrumbName: string }[] = [],
        ): { path: string; breadcrumbName: string }[] => [
          {
            path: '/',
            breadcrumbName: intl.formatMessage({ id: 'menu.home', defaultMessage: 'Home' }),
          },
          ...routers,
        ]}
        footerRender={(): React.ReactNode =>
          location.pathname.includes('/dashboard') ? <Footer /> : false
        }
        menuDataRender={menuDataRender}
        // menuDataRender={() => dummyMenuData}
        formatMessage={intl.formatMessage}
        headerContentRender={() => (
          <RightContent
            
          />
        )}
        {...props}
        {...settings}
      >
        <Outlet />
      </ProLayout>
  );
};

export default BasicLayout;

How To Reproduce

After updating the Umi version, the menu is not loading.
image

Expected behavior 1. 2.
Before updating the Umi version, the menu is loading correctly. I need to render the menu on the left side.
image

Context

umi: ^4.3.28
antd: ^5.21.5
react: ^18.2.0
Node.js: v18.18.0
@ant-design/pro-components: ^2.8.1
@ant-design/pro-layout": ^7.4.0

@IndhuKandhaiya
Copy link
Author

@fz6m Can you please help us on the above issue. We are trying to fix the menu rendering problem. But still we didn't get any positive solution.

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

No branches or pull requests

1 participant