MenuComponent and React Router

Hi,

How can I use react-router with MenuComponent?
When I put <Link> (from react-router-dom) into template:

menuTemplate = (data) => {
  return (<Link to={data.url}>{data.text}</Link>);
}

render() {
  return (
    <MenuComponent items={this.props.items} template={this.menuTemplate} />
  )
}

I got error: "Error: Invariant failed: You should not use <Link> outside a <Router>".
(My <App> is wrapped by <Router>, and when I create links by <Link> outside MenuComponent everything works properly.)


1 Reply

AD Arunkumar Devendiran Syncfusion Team April 19, 2020 04:29 PM UTC

Hi adgr, 
 
Sorry for the late reply. 
 
We have checked your reported your query and could you please share us in which case you are trying to use <Link> tag outside of the <Router>. Could you please share your exact scenario?  So, that we can analyze based on that and provide you a better solution. The information provided would be great help for us to proceed further. 
 
Regards, 
Arunkumar D 


Loader.
Up arrow icon