Skip to content

Instantly share code, notes, and snippets.

@adavia
Last active December 20, 2017 02:54
Show Gist options
  • Select an option

  • Save adavia/beb2b95f06641ddbb9d98f3d8e6eeef8 to your computer and use it in GitHub Desktop.

Select an option

Save adavia/beb2b95f06641ddbb9d98f3d8e6eeef8 to your computer and use it in GitHub Desktop.
HOC Route render
return (
<div>
<Switch location={isModal ? this.prevLocation : location}>
<Route path="/" exact component={withAuth(Main)} />
<Route path="/auth/register" exact component={Register} />
<Route path="/auth/login" exact component={Login} />
<Route path="/users" exact component={withAuth(ListUsers)} />
<Route
path='/clients/:id/edit'
render={() => withAuth(
<div>
{isModal ? null : <Main />}
<ClientEdit onClose={() => this.props.history.push('/')} />
</div>
)}
/>
</Switch>
{isModal ?
<Route
path='/clients/new'
component={withAuth(ClientNew)}
/>
: null}
{isModal ?
<Route
path='/clients/:id/edit'
component={withAuth(ClientEdit)}
/>
: null}
</div>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment