github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/hooks/flamegraphSharedQuery.hook.ts (about)

     1  import { useState, Dispatch, SetStateAction } from 'react';
     2  
     3  interface SharedQueryHookProps {
     4    searchQuery?: string;
     5    onQueryChange: Dispatch<SetStateAction<string | undefined>>;
     6    syncEnabled: string | boolean;
     7    toggleSync: Dispatch<SetStateAction<boolean | string>>;
     8  }
     9  
    10  const useFlamegraphSharedQuery = (): SharedQueryHookProps => {
    11    const [searchQuery, onQueryChange] = useState<string | undefined>();
    12    const [syncEnabled, toggleSync] = useState<boolean | string>(false);
    13  
    14    return {
    15      searchQuery,
    16      onQueryChange,
    17      syncEnabled,
    18      toggleSync,
    19    };
    20  };
    21  
    22  export default useFlamegraphSharedQuery;