mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
31 lines
814 B
TypeScript
31 lines
814 B
TypeScript
import {useContext} from 'react';
|
|
|
|
import type {
|
|
FlamegraphStateDispatch,
|
|
FlamegraphStateValue,
|
|
} from '../flamegraphStateProvider/flamegraphContext';
|
|
import {
|
|
FlamegraphStateDispatchContext,
|
|
FlamegraphStateValueContext,
|
|
} from '../flamegraphStateProvider/flamegraphContext';
|
|
|
|
export function useFlamegraphState(): FlamegraphStateValue {
|
|
const context = useContext(FlamegraphStateValueContext);
|
|
|
|
if (context === null) {
|
|
throw new Error('useFlamegraphState called outside of FlamegraphStateProvider');
|
|
}
|
|
|
|
return context;
|
|
}
|
|
|
|
export function useDispatchFlamegraphState(): FlamegraphStateDispatch {
|
|
const context = useContext(FlamegraphStateDispatchContext);
|
|
|
|
if (context === null) {
|
|
throw new Error('useFlamegraphState called outside of FlamegraphStateProvider');
|
|
}
|
|
|
|
return context;
|
|
}
|