first
This commit is contained in:
35
src/providers/MainLayoutProvider.tsx
Normal file
35
src/providers/MainLayoutProvider.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import React, {
|
||||
Dispatch,
|
||||
PropsWithChildren,
|
||||
SetStateAction,
|
||||
createContext,
|
||||
useContext,
|
||||
useState
|
||||
} from 'react';
|
||||
|
||||
interface MainLayoutContextInterface {
|
||||
contentClass: string;
|
||||
setContentClass: Dispatch<SetStateAction<string>>;
|
||||
footerClass: string;
|
||||
setFooterClass: Dispatch<SetStateAction<string>>;
|
||||
}
|
||||
|
||||
export const MainLayoutContext = createContext(
|
||||
{} as MainLayoutContextInterface
|
||||
);
|
||||
|
||||
const MainLayoutProvider = ({ children }: PropsWithChildren) => {
|
||||
const [contentClass, setContentClass] = useState('');
|
||||
const [footerClass, setFooterClass] = useState('');
|
||||
return (
|
||||
<MainLayoutContext.Provider
|
||||
value={{ contentClass, setContentClass, footerClass, setFooterClass }}
|
||||
>
|
||||
{children}
|
||||
</MainLayoutContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useMainLayoutContext = () => useContext(MainLayoutContext);
|
||||
|
||||
export default MainLayoutProvider;
|
||||
Reference in New Issue
Block a user