mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Add config and settings!
This commit is contained in:
1 parent
16004a9a86
commit
3900b9fa83
14 files changed
+90
-9
No files matched your search
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"4gNetowrk": "AT&T",
|
||||
"language": "en_US"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { createContext, useContext, useEffect, useState } from "react";
|
||||
import _set from "lodash/set";
|
||||
import Default from "../default.json";
|
||||
|
||||
export const ConfigContext = createContext(Default);
|
||||
|
||||
export const useConfig = (Context = ConfigContext) => {
|
||||
const configCtx = useContext(Context);
|
||||
const [config, _setConfig] = useState({ ...configCtx });
|
||||
|
||||
useEffect(() => {
|
||||
_setConfig({ ...configCtx });
|
||||
}, [configCtx]);
|
||||
|
||||
const setConfig = (key, value) => {
|
||||
const state = { ...config };
|
||||
_setConfig(_set(state, key, value));
|
||||
};
|
||||
return [config, setConfig];
|
||||
};
|
||||
Reference in new issue
Block a user