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.

Revisions

  1. Hoony revised this gist Nov 25, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions protectedComponent.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    const ProtectedComponent = ({ Layout, Component, path, ...rest }) => {
    const ProtectedComponent = ({ Component, path }) => {
    switch (this.state.token) {
    case '':
    return <LoadingContainer />
    case 'FAILED':
    return <DefaultLayout path={path} Component={LoadingContainer} />
    case 'UNAUTHORIZED':
    return <Redirect to="/login" />
    default:
    return <DefaultLayout {...rest} path={path} component={Component} />
    return <DefaultLayout path={path} component={Component} />
    }
    }
  2. Hoony renamed this gist Sep 3, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. Hoony revised this gist Sep 3, 2017. 1 changed file with 10 additions and 11 deletions.
    21 changes: 10 additions & 11 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,10 @@

    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} />
    }
    }
    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} />
    }
    }
  4. Hoony created this gist Sep 3, 2017.
    11 changes: 11 additions & 0 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@

    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} />
    }
    }