useStatusPageList.tsx 499 B

12345678910111213141516171819202122
  1. import {useCallback, useEffect, useState} from 'react';
  2. import {useIsMountedRef} from 'sentry/utils/useIsMountedRef';
  3. export function useStatusPageList() {
  4. const isMountedRef = useIsMountedRef();
  5. const [mod, setMod] = useState<any>({});
  6. const loader = useCallback(async () => {
  7. const loaded = await import('@sentry/status-page-list');
  8. if (isMountedRef.current) {
  9. setMod(loaded);
  10. }
  11. }, [isMountedRef]);
  12. useEffect(() => {
  13. loader();
  14. }, [loader]);
  15. return mod;
  16. }