PrivateRoute.js 419 Bytes
Newer Older
Lee SeoYeon's avatar
.    
Lee SeoYeon 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 { Route, Redirect } 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