mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
28 lines
673 B
TypeScript
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;
|
|
}
|