Answer the question
In order to leave comments, you need to log in
How to remove menu redraw after clicking on Menu.Item in React?
Using antd I have a menu whose Menu.Items I form dynamically, getting data from the database (routes for navigating pages and their names)
<Menu
mode="inline"
onOpenChange={this.onOpenChange}
>
{accessData?.length > 0 ? (
<SubMenu key="sub1" title={'Docs'}>
{accessData.map(item => (
item.parent_route === 'docs' ?
<Menu.Item key={item.routeId}>
<Link to={item.route}>{item.name}</Link>
</Menu.Item> : null
))}
</SubMenu>
) : null}
</Menu>
componentDidMount() {
this.fetchData();
}
fetchData = async() => {
const { type, content: access } = await insertAccess(User.decode());
if (type === 'ok') {
this.setState({ accessData: access });
} else {
this.setState({ accessData: [] });
}
}
<SubMenu key="sub1" title={'Docs'}>
<Menu.Item key="1">
<Link to="/cabinet">'incoming'</Link>
</Menu.Item>
<Menu.Item key="2">
<Link to="/cabinet/outcoming">'outcoming'</Link>
</Menu.Item>
<Menu.Item key="3">
<Link to="/cabinet/administrative">'administrative'</Link>
</Menu.Item>
</SubMenu>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question