useFlamegraphPreferences.ts 444 B

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