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

Menu.Item does not support React Fragments #16962

Closed
1 task
xianghongai opened this issue Jun 5, 2019 · 2 comments · Fixed by #26656
Closed
1 task

Menu.Item does not support React Fragments #16962

xianghongai opened this issue Jun 5, 2019 · 2 comments · Fixed by #26656
Assignees

Comments

@xianghongai
Copy link

xianghongai commented Jun 5, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

This question does not require ‘Reproduction link’, so this link is invalid.

Steps to reproduce

When dynamically constructing menu.item, three states,

  • state '0' shows one,
  • state '1' shows another,
  • and state '2' displays two items.
const tableData = [
  { name: 'item 1', status: 0 },
  { name: 'item 2', status: 1 },
  { name: 'item 3', status: 2 }
]

const status = [
  { key: 0, text: "action a" },
  { key: 1, text: "action b" }
]

function MenuItem() {
  return (
    tableData.forEach((dataItem) => {
      status.some((statusItem) => {
        if (dataItem.status === statusItem.key) {
          if (statusItem.key === 0) {
            return <Menu.Item key="action a">action a</Menu.Item>;
          } else if (statusItem.key === 1) {
            return <Menu.Item key="action b">action b</Menu.Item>;
          } else {
            // This condition is currently not supported
            return <>
              <Menu.Item key="action a">action a</Menu.Item>
              <Menu.Item key="action b">action b</Menu.Item>
            </>;
          }

          return true;
        }
      });

    });
  )
}

What is expected?

Menu.Item support React 'Fragments'

What is actually happening?

Menu.Item renders the list ClassName is undefined-item, instead of the expected 'ant-menu-item'.

Environment Info
antd 3.19.2
React 16.8.6
System windows 10
Browser chrome v74

This question does not require ‘Reproduction link’, so this link is invalid.

@abz53378
Copy link
Contributor

abz53378 commented Jun 6, 2019

try this

return [
  <Menu.Item key="action a">action a</Menu.Item>,
  <Menu.Item key="action b">action b</Menu.Item>
];

@xianghongai
Copy link
Author

class name: ant-menu-item ant-menu-item

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 a pull request may close this issue.

3 participants