Skip to content

Instantly share code, notes, and snippets.

@brownsmith
Last active October 10, 2017 13:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save brownsmith/e9bcf2b3bfa76f9dbc745a3035e3fbac to your computer and use it in GitHub Desktop.
Passing children about in JSX
getMain = (children) => {
return (
<Switch>
<Route path={pathJoin(this.baseUrl, '/path/one')}>
<main className={styles.something}>
{children}
</main>
</Route>
<Route path={pathJoin(this.baseUrl, '/path/two')}>
<main className={styles.somethingElse}>
{children}
</main>
</Route>
</Switch>
);
}
render() {
return (
{this.getMain(
<Switch>
<Route exact path={this.baseUrl} render={() => (<Redirect to={pathJoin(this.baseUrl, '/my/path/here')}/>)}/>
// etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment