Skip to content

Instantly share code, notes, and snippets.

@hoony-o-1
Last active November 25, 2017 15:49
Show Gist options
  • Select an option

  • Save hoony-o-1/8413ef0576fd02f01e7f7c3b795a8b11 to your computer and use it in GitHub Desktop.

Select an option

Save hoony-o-1/8413ef0576fd02f01e7f7c3b795a8b11 to your computer and use it in GitHub Desktop.
const ProtectedComponent = ({ Layout, Component, path, ...rest }) => {
switch (this.state.token) {
case '':
return <LoadingContainer />
case 'FAILED':
return <Redirect to="/login" />
default:
return <DefaultLayout {...rest} path={path} component={Component} />
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment