PrivateRoutes.js 445 Bytes
Newer Older
Spark's avatar
Spark 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 { isLogined } from '../utils/Auth';

function PrivateRoute({ path, children }) {
    if (isLogined()) {
        return (
            <Route path={path}>
                {children}
            </Route>
        )
    } else {
        alert('권한이 없습니다')
        return (
            <Redirect to='/' />
        )
    }
}
export default PrivateRoute