-
Notifications
You must be signed in to change notification settings - Fork 1
/
AppContext.js
37 lines (32 loc) · 1.05 KB
/
AppContext.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
import { createContext, useContext, useState } from "react";
const AppContext = createContext();
export const AppProvider = ({ children }) => {
const [fetchingResponse, setFetchingResponse] = useState(false);
const [todaysChatList, setTodaysChatList] = useState([]);
const [last7DaysChatList, setLast7DaysChatList] = useState([]);
const [olderChatList, setOlderChatList] = useState([]);
const [searchResult, setSearchResult] = useState([]);
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
const contextValue = {
fetchingResponse,
setFetchingResponse,
todaysChatList,
setTodaysChatList,
last7DaysChatList,
setLast7DaysChatList,
olderChatList,
setOlderChatList,
searchResult,
setSearchResult,
isSidebarOpen,
setIsSidebarOpen,
};
return (
<AppContext.Provider value={contextValue}>
{children}
</AppContext.Provider>
);
};
export const useAppContext = () => {
return useContext(AppContext);
};