-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathappState.js
55 lines (49 loc) · 1.42 KB
/
appState.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
48
49
50
51
52
53
54
55
import React, { createContext, useState, useContext } from "react";
const AppStateContext = createContext();
export function AppStateProvider({ children }) {
const [imageUrl, setImageUrl] = useState(null);
const [isUploading, setIsUploading] = useState(false);
const [progressIncrement, setProgress] = useState(null);
const [isGenerating, setIsGenerating] = useState(false);
const [generatedAvatar, setGeneratedAvatars] = useState(null);
const [previewSize, setSize] = useState("square");
// Enter your Cloudinary UploadPreset and CloudName here to enable uploading to your cloudinary bucket.
const cloudinaryUploadPreset = "";
const cloudinaryCloudName = "";
// Enter your Make API key and Template URL here
const makeAPIKey = "";
const makeTemplateURL = "";
;
const value = {
imageUrl,
setImageUrl,
isUploading,
setIsUploading,
progressIncrement,
setProgress,
isGenerating,
setIsGenerating,
generatedAvatar,
setGeneratedAvatars,
previewSize,
setSize,
cloudinaryUploadPreset,
cloudinaryCloudName,
makeAPIKey,
makeTemplateURL,
};
return (
<AppStateContext.Provider value={value}>
{children}
</AppStateContext.Provider>
);
}
export function useAppState() {
const context = useContext(AppStateContext);
if (!context) {
throw new Error(
"You probably forgot a <AppStateProvider> context provider!"
);
}
return context;
}