Download NetflixClone/src/context/Authentication.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 729 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/NetflixClone/src/context/Authentication.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/NetflixClone/src/context/Authentication.js
-
curl -L -o Authentication.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/NetflixClone/src/context/Authentication.js
729 Bytes
| import React, { useState } from 'react' | |
| export const AuthenticationContext = React.createContext({ | |
| authenticated: false, | |
| login: () => { }, | |
| logout: () => {} | |
| }) | |
| const AuthenticationContextProvider = (props) => { | |
| const [authenticated, setAuthenticated] = useState(false) | |
| const loginHandler = () => { | |
| setAuthenticated(true) | |
| } | |
| const logoutHandler = () => { | |
| setAuthenticated(false) | |
| } | |
| return ( | |
| <AuthenticationContext.Provider value={{ | |
| authenticated: authenticated, login: loginHandler, | |
| logout: logoutHandler | |
| }}> | |
| {props.children} | |
| </AuthenticationContext.Provider> | |
| ) | |
| } | |
| export default AuthenticationContextProvider |