Migrate from redux to context

This commit is contained in:
MD. Ariful Alam committed 2021-09-16 00:30:22 +06:00
1 parent d5c715e16e
commit 8f167cc940
21 files changed
+157 -446

No files matched your search

+15
View File
@@ -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>
);
}
+16
View File
@@ -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>
);
}