Spaces:
Build error
Build error
File size: 805 Bytes
0bfe2e3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import React, { createContext, useContext, useState } from 'react';
interface OptionsContextType {
isOptionsEnabled: boolean;
enableOptions: () => void;
}
const OptionsContext = createContext<OptionsContextType | undefined>(undefined);
export function OptionsProvider({ children }: { children: React.ReactNode }) {
const [isOptionsEnabled, setIsOptionsEnabled] = useState(false);
const enableOptions = () => {
setIsOptionsEnabled(true);
};
return (
<OptionsContext.Provider value={{ isOptionsEnabled, enableOptions }}>
{children}
</OptionsContext.Provider>
);
}
export function useOptions() {
const context = useContext(OptionsContext);
if (context === undefined) {
throw new Error('useOptions must be used within a OptionsProvider');
}
return context;
}
|