mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
sweet lander
This commit is contained in:

committed by
Geoff Seemueller

parent
818e0e672a
commit
c26d2467f4
25
packages/client/src/components/contexts/ComponentContext.tsx
Normal file
25
packages/client/src/components/contexts/ComponentContext.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import React, { createContext, useContext, useState } from 'react';
|
||||
|
||||
type ComponentContextType = {
|
||||
enabledComponent: string;
|
||||
setEnabledComponent: (component: string) => void;
|
||||
};
|
||||
|
||||
const ComponentContext = createContext<ComponentContextType>({
|
||||
enabledComponent: '',
|
||||
setEnabledComponent: () => {},
|
||||
});
|
||||
|
||||
export const useComponent = () => useContext(ComponentContext);
|
||||
|
||||
export const ComponentProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const [enabledComponent, setEnabledComponent] = useState<string>('');
|
||||
|
||||
return (
|
||||
<ComponentContext.Provider value={{ enabledComponent, setEnabledComponent }}>
|
||||
{children}
|
||||
</ComponentContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export default ComponentContext;
|
Reference in New Issue
Block a user