Backstage
    Preparing search index...
    • Returns the style's loading state.

      Parameters

      • element: Element | null

        which is the ShadowRoot tree.

      Returns boolean

      a boolean value, true if styles are being loaded.

      Here's an example that updates the sidebar position only after styles are calculated:

      import {
      TechDocsShadowDom,
      useShadowDomStylesLoading,
      } from '@backstage/plugin-techdocs-react';

      export const TechDocsReaderPageContent = () => {
      // ...
      const dom = useTechDocsReaderDom(entity);
      const isStyleLoading = useShadowDomStylesLoading(dom);

      const updateSidebarPosition = useCallback(() => {
      //...
      }, [dom]);

      useEffect(() => {
      if (!isStyleLoading) {
      updateSidebarPosition();
      }
      }, [isStyleLoading, updateSidebarPosition]);

      const handleDomAppend = useCallback(
      (newShadowRoot: ShadowRoot) => {
      setShadowRoot(newShadowRoot);
      },
      [setShadowRoot],
      );

      return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;
      };