diff --git a/webapp/src/context.js b/webapp/src/context.js new file mode 100644 index 0000000..abbd8c4 --- /dev/null +++ b/webapp/src/context.js @@ -0,0 +1,3 @@ +import React from 'react' + +export const TokenContext = React.createContext() diff --git a/webapp/src/index.js b/webapp/src/index.js index e76c70b..a5fa1b9 100644 --- a/webapp/src/index.js +++ b/webapp/src/index.js @@ -10,13 +10,13 @@ import { import { CssBaseline } from '@material-ui/core'; -import UserContext from './user-context' +import { TokenContext } from './context' import Login from './pages/login' import Home from './pages/home' const Secure = ({children}) => { - const { token } = useContext(UserContext) + const { token } = useContext(TokenContext) if (!token) { return } @@ -28,10 +28,10 @@ const App = () => { const [token, setToken] = useState(localStorage.getItem('token')) return ( - - - - + + + + @@ -41,9 +41,9 @@ const App = () => { - - - + + + ) } diff --git a/webapp/src/pages/home.js b/webapp/src/pages/home.js index 84b337d..043c4fa 100644 --- a/webapp/src/pages/home.js +++ b/webapp/src/pages/home.js @@ -4,11 +4,11 @@ import { Button } from '@material-ui/core'; -import UserContext from '../user-context' +import { TokenContext } from '../context' const Home = () => { - const { token, setToken } = useContext(UserContext) + const { token, setToken } = useContext(TokenContext) const handleLogout = (e) => { e.preventDefault() diff --git a/webapp/src/pages/login.js b/webapp/src/pages/login.js index 25d94c7..7f5688a 100644 --- a/webapp/src/pages/login.js +++ b/webapp/src/pages/login.js @@ -7,10 +7,10 @@ import { } from '@material-ui/core'; import client from '../client' -import UserContext from '../user-context' +import { TokenContext } from '../context' const Login = () => { - const { token, setToken } = useContext(UserContext) + const { token, setToken } = useContext(TokenContext) if (token) { return diff --git a/webapp/src/user-context.js b/webapp/src/user-context.js deleted file mode 100644 index d254589..0000000 --- a/webapp/src/user-context.js +++ /dev/null @@ -1,5 +0,0 @@ -import React from 'react' - -const UserContext = React.createContext() - -export default UserContext