mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-09 19:44:56 +02:00
27 lines
685 B
JavaScript
27 lines
685 B
JavaScript
import React from "react";
|
|
import { Switch, Route } from "react-router";
|
|
|
|
function renderRoutes(routes, extraProps = {}, switchProps = {}) {
|
|
return routes ? (
|
|
<Switch {...switchProps}>
|
|
{routes.map((route, i) => (
|
|
<Route
|
|
key={route.key || i}
|
|
path={route.path}
|
|
exact={route.exact}
|
|
strict={route.strict}
|
|
render={props =>
|
|
route.render ? (
|
|
route.render({ ...props, ...extraProps, route: route })
|
|
) : (
|
|
<route.component {...props} {...extraProps} route={route} />
|
|
)
|
|
}
|
|
/>
|
|
))}
|
|
</Switch>
|
|
) : null;
|
|
}
|
|
|
|
export default renderRoutes;
|