useFlamegraphSearch.ts 424 B

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