Using react-router-dom in server-side react creates an error.
Invariant Violation: Browser history needs a DOM
I am using react-router-dom BrowserRouter to render my component in div if url match my component path.
const routes = [
{ path: 'dashboard',
exact: true,
component: Dashboard
},
{ path: 'notification',
exact: true,
component: Notification
}
];
and then use this code to target specific div to render my component:
<div>
{ routes.map((route, index) => (
<Route
key={index}
path={`${match.url}/${route.path}`}
exact={route.exact}
/>
))}
</div>
But this code work only in client-side react. How can I implement this to server-side?