Files
2024-02-15 17:01:50 +00:00

28 lines
673 B
TypeScript

import {useContext} from 'react';
import type {FlamegraphTheme} from './flamegraphTheme';
import {
FlamegraphThemeContext,
FlamegraphThemeMutationContext,
} from './flamegraphThemeProvider';
export function useFlamegraphTheme(): FlamegraphTheme {
const ctx = useContext(FlamegraphThemeContext);
if (!ctx) {
throw new Error('useFlamegraphTheme was called outside of FlamegraphThemeProvider');
}
return ctx;
}
export function useMutateFlamegraphTheme() {
const ctx = useContext(FlamegraphThemeMutationContext);
if (!ctx) {
throw new Error(
'useMutateFlamegraphTheme was called outside of FlamegraphThemeProvider'
);
}
return ctx;
}