Skip to content

Instantly share code, notes, and snippets.

@dagron
Last active August 7, 2019 12:47
Show Gist options
  • Select an option

  • Save dagron/9cd4b738bf7c15874df273bbc19f9316 to your computer and use it in GitHub Desktop.

Select an option

Save dagron/9cd4b738bf7c15874df273bbc19f9316 to your computer and use it in GitHub Desktop.
react
const switchRoutes = (mix_props) => (
<Switch>
{routes.map((prop, key) => {
if (prop.layout === "/admin") {
return (
<Route
path={prop.layout + prop.path}
component={(route_props) => <prop.component {...route_props, ...mix_props} />}
key={key}
/>
);
}
return null;
})}
<Redirect from="/admin" to="/admin/dashboard" />
</Switch>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment