Skip to content

Instantly share code, notes, and snippets.

@tomitrescak
Last active October 20, 2016 12:48
Show Gist options
  • Save tomitrescak/97820edd951979af4b498cb585c3057f to your computer and use it in GitHub Desktop.
Save tomitrescak/97820edd951979af4b498cb585c3057f to your computer and use it in GitHub Desktop.
import { BrowserRoute, Match, Miss } from 'react-router';
import { MainLayout, HomePage, Other } from './components';
const MatchWithMainLayout = ({ exactly, pattern, component: Component }: any) => {
return (
<Match exactly={exactly} pattern={pattern} render={(props: any) => (
<MainLayout><Component {...props} /></MainLayout>
)} />
);
};
const AppRoutes = () => {
return (
<BrowserRouter>
<div>
<MatchWithMainLayout exactly pattern="/" component={HomePage} />
<MatchWithMainLayout pattern="/:foo/bar" component={(props: any) => <Other {...props} foo="bar" />} />
<Miss component={NotFound} />
</div>
</BrowserRouter>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment