PrivateRoute.js 419 Bytes
Newer Older
우지원's avatar
우지원 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import React from 'react'
import { Redirect, Route } from 'react-router-dom'
import { isAuthenticated } from '../utils/auth'

function PrivateRoute({path, children}) {
    if (isAuthenticated()) {
        return (
            <Route path={path}>
                {children}
            </Route>
        )
    } else {
        return (
            <Redirect to='./login' />
        )
    }
}

export default PrivateRoute