useFlamegraphZoomPosition.tsx 436 B

12345678910111213141516
  1. import {useContext} from 'react';
  2. import {
  3. FlamegraphStateContext,
  4. FlamegraphStateContextValue,
  5. } from './flamegraphStateProvider';
  6. export function useFlamegraphZoomPositionValue(): FlamegraphStateContextValue[0]['position'] {
  7. const context = useContext(FlamegraphStateContext);
  8. if (context === null) {
  9. throw new Error('useFlamegraphState called outside of FlamegraphStateProvider');
  10. }
  11. return context[0].position;
  12. }