mirror of
https://github.com/NohamR/gitprofile.git
synced 2026-11-25 15:29:54 +00:00
Add contexts
This commit is contained in:
1 parent
6979ee8c5c
commit
cf043dab4c
2 files changed
+31
No files matched your search
@@ -0,0 +1,15 @@
|
|||||||
|
import { createContext, useState } from 'react';
|
||||||
|
|
||||||
|
const initialValue = true;
|
||||||
|
|
||||||
|
export const LoadingContext = createContext();
|
||||||
|
|
||||||
|
export const LoadingProvider = (props) => {
|
||||||
|
const [loading, setLoading] = useState(initialValue);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<LoadingContext.Provider value={[loading, setLoading]}>
|
||||||
|
{props.children}
|
||||||
|
</LoadingContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { createContext, useState } from 'react';
|
||||||
|
import { getInitialTheme } from '../helpers/utils';
|
||||||
|
|
||||||
|
const initialValue = getInitialTheme();
|
||||||
|
|
||||||
|
export const ThemeContext = createContext();
|
||||||
|
|
||||||
|
export const ThemeProvider = (props) => {
|
||||||
|
const [theme, setTheme] = useState(initialValue);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ThemeContext.Provider value={[theme, setTheme]}>
|
||||||
|
{props.children}
|
||||||
|
</ThemeContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in new issue
Block a user