2

I'm new to semantic-ui. I try to map Menu Items with lodash. But unfortunately I can't routing my elements.

Here is my code

</Menu.Item>
    {_.map(menuItems, item => <Menu.Item {...item} />)}
</Menu.Menu>

And its my menu object

const menuItems= [
  { as: "a", content: "About Us", key: "about", path:"/about"},
  { as: "a", content: "Contact", key: "contact", path:"/contact"}
];

so I want to Link my menu with react-router. I try everythink but i cant solve the problem

It returns

 <a path="/about" ........>

But I want to get

<Link path="/about".....>

How can i do solve the problem? Thank you.

1 Answer 1

1

You can pass it as={Link}.

So basically your objects should reflect that:

const menuItems= [
  { as: Link, content: "About Us", key: "about", path:"/about"},
  { as: Link, content: "Contact", key: "contact", path:"/contact"}
];
Sign up to request clarification or add additional context in comments.

3 Comments

I try that. It returns "Warning: <Link /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements." and return Links not clickable.
@Ryoush note that it should be as: Link (Link is a variable) and not as:'Link' (string)
You have returned me from a big mistake. I'm never thinking of that. Thank you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.