Skip to content

Instantly share code, notes, and snippets.

@brownsmith
Last active Oct 10, 2017
Embed
What would you like to do?
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