-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuthContext.js
47 lines (42 loc) · 959 Bytes
/
AuthContext.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, { useState, useContext } from "react";
const AuthContext = React.createContext();
// useAuth hook
export function useAuth() {
return useContext(AuthContext);
}
// Create the Context
export function AuthProvider(props) {
const [username, setUsername] = useState(null);
const [isLogin, setLogin] = useState(false);
const [currentSection, setSection] = useState("Login");
const [updateInfo, setUpdate] = useState({});
const categories = [
"rock",
"jazz",
"classical",
"hip-hop",
"electronic",
"country",
"blues",
"pop",
"folk",
"undefined",
];
const [statsData, setStatsData] = useState([]);
const value = {
username,
setUsername,
isLogin,
setLogin,
currentSection,
setSection,
updateInfo,
setUpdate,
categories,
statsData,
setStatsData,
};
return (
<AuthContext.Provider value={value}>{props.children}</AuthContext.Provider>
);
}