"Component not initialized"

WebViewer Version: ^10.0.1

Do you have an issue with a specific file(s)? /core/webviewer-core.min.js :: e.prototype.GW :: line 2926" data: no

Can you reproduce using one of our samples or online demos? no

Are you using the WebViewer server? No
Does the issue only happen on certain browsers? Yes, Firefox
Is your issue related to a front-end framework? Possibly, using React ^18.2.0
Is your issue related to annotations? No

Please give a brief summary of your issue:

function ApryseViewer(props) {
  const {
  } = props

  const viewer = useRef(null);
  const [presignedUrl, setPresignedUrl] = useState(null);
  const { instance, setInstance } = useContext(WebViewerContext);

  useEffect(() => {
    const getPresignedUrl = async () => {
      const url = await signedUrlGET(file.awsId);
  }, [file.awsId, signedUrlGET]);

  const loadVideoFile = useCallback(async (inst, url, f) => {
    const { loadVideo } = await initializeVideoViewer(inst, { license: apryseLicenseKey });
    loadVideo(url, { fileId: f.id });
  }, []);

  const loadAudioFile = useCallback(async (inst, url, f) => {
    const { loadAudio } = await initializeAudioViewer(inst, {
      license: apryseLicenseKey,
      AudioComponent: Waveform,
    loadAudio(url, { fileId: f.id });
  }, []);

  useEffect(() => {
    if (!presignedUrl) return;

    const isVideo = isVideoFile(file.name);
    const isAudio = isAudioFile(file.name);

      path: '/',
      licenseKey: apryseLicenseKey,
      fullAPI: true,
      ...(isVideo || isAudio ? {} : {
        initialDoc: presignedUrl,
        extension: fileExtensionParser(file.name),
    }, viewer.current).then((inst) => {
      const docLoadedHandler = () => {

        if (isVideo) loadVideoFile(inst, presignedUrl, file);
        if (isAudio) loadAudioFile(inst, presignedUrl, file);
      inst.UI.addEventListener(inst.UI.Events.DOCUMENT_LOADED, docLoadedHandler);

      return () => {
        inst.UI.removeEventListener(inst.UI.Events.DOCUMENT_LOADED, docLoadedHandler);
        if (inst && inst.dispose) {
  // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [presignedUrl, webViewerOptions, file, loadVideoFile, loadAudioFile]);

  useEffect(() => {
    if (!instance) return;
  }, [page, instance]);

  return (
    <div className={className} ref={viewer}>
      {!instance && <Spinner />}

Upon trying to initialize this component I receive the following error from the Firefox browser:

[Exception... "Component not initialized"  nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)"  location: "JS frame :: http://localhost:3000/core/webviewer-core.min.js :: e.prototype.GW :: line 2926"  data: no]

This does NOT occur with the latest chrome web browser.

Please describe your issue and provide steps to reproduce it:

  1. Follow the react guide for initializing the Webviewer
  2. Attempt to manipulate ‘Core’ or ‘UI’ after the instance has been initialized and the documented is loaded
  3. Confirm error occurs on Firefox, but not Chrome

Found the error.

I was using the React guide along with the React Context guide for sharing instance state across components. The instance state was incorrectly persisting when the viewer component unmount due to nested routes. This caused logic to fire thinking that an instance was loaded but only in context thus causing the initialization error. I added an unmounting effect to setInstance(null) which resolved the issue.

Great, Thanks for letting us know you solved the issue. If you are good we will mark this issue as solved for now.