Skip to content

Instantly share code, notes, and snippets.

@nesbtesh
Created April 10, 2020 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesbtesh/e55704a936b9bf8570cc4f0b2840adff to your computer and use it in GitHub Desktop.
Save nesbtesh/e55704a936b9bf8570cc4f0b2840adff to your computer and use it in GitHub Desktop.
const App = ({ routes, initialData, initialToken, menus }) => (
<Switch>
{routes.map((route, index) => {
// pass in the initialData from the server or window.DATA for this
// specific route
return (
<Route
key={index}
path={route.path}
exact={route.exact}
render={props =>
React.createElement(route.component, {
...props,
privateTemplate: route.private,
initialToken: initialToken,
jsonSettings: initialData[initialData.length -2],
initialData: initialData ? initialData[index] : null,
})}
/>
);
})}
</Switch>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment