SPFx Extensions is not loading when accessing Documents Page.

%3CLINGO-SUB%20id%3D%22lingo-sub-1962451%22%20slang%3D%22en-US%22%3ESPFx%20Extensions%20is%20not%20loading%20when%20accessing%20Documents%20Page.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1962451%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20got%20an%20SPFx%20Extension%20which%20works%20fine%20until%20user%20pick%20any%20List%20from%20QuickLaunch%20Menu.%20It%20throws%20an%20error%20that%20reads%3A%3C%2FP%3E%3CP%3E%3CEM%3EVM18%3A1%20Uncaught%20SyntaxError%3A%20Unexpected%20token%20r%20in%20JSON%20at%20position%200%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3Esp-pages-assembly_pl-pl_80ffc67e026290d635d98a5e7caa0077.js%3A1%20Uncaught%20TypeError%3A%20Cannot%20read%20property%20'querySelectorAll'%20of%20null%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhich%20I%20inspected%20and%20it%20seems%20to%20me%20like%20it%20has%20something%20to%20do%20with%20highlihting%20elements.%20If%20I%20refresh%20the%20page%20(by%20F5%20or%20just%20click%20one%20more%20time%20on%20same%20List%20in%20QuickLaunch)%20the%20SPFx%20Extension%20works%20perfect.%20It%20looks%20like%20due%20to%20this%20error%20the%20extension's%20code%20isn't%20even%20loaded%20to%20the%20site.%3C%2FP%3E%3CP%3EDid%20anyone%20stumbled%20across%20anything%20like%20that%3F%20I%20feel%20like%20I'm%20hitting%20a%20wall%20here%20since%20I%20can't%20event%20work%20it%20around%20because%20my%20code%20isn't%20even%20loaded.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Iwo_Misztal_0-1607344065663.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F238253i0B485DA64A866081%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Iwo_Misztal_0-1607344065663.png%22%20alt%3D%22Iwo_Misztal_0-1607344065663.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2032980%22%20slang%3D%22en-US%22%3ERe%3A%20SPFx%20Extensions%20is%20not%20loading%20when%20accessing%20Documents%20Page.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2032980%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F893308%22%20target%3D%22_blank%22%3E%40Iwo_Misztal%3C%2FA%3E%26nbsp%3Btry%20to%20add%20extention%20to%20the%20bottom%2Ffooter%20of%20the%20page%2C%20usually%20it%20is%20layout%20or%20JS%20which%20are%20loaded%20by%20default%20issue%2C%20I%20document%20view%20you%20might%20need%20to%20preload%2Fwait%20for%20something%20else%20to%20complete%20first.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I've got an SPFx Extension which works fine until user pick any List from QuickLaunch Menu. It throws an error that reads:

VM18:1 Uncaught SyntaxError: Unexpected token r in JSON at position 0

sp-pages-assembly_pl-pl_80ffc67e026290d635d98a5e7caa0077.js:1 Uncaught TypeError: Cannot read property 'querySelectorAll' of null

 

Which I inspected and it seems to me like it has something to do with highlihting elements. If I refresh the page (by F5 or just click one more time on same List in QuickLaunch) the SPFx Extension works perfect. It looks like due to this error the extension's code isn't even loaded to the site.

Did anyone stumbled across anything like that? I feel like I'm hitting a wall here since I can't event work it around because my code isn't even loaded.

 

Iwo_Misztal_0-1607344065663.png

 

2 Replies

@Iwo_Misztal try to add extention to the bottom/footer of the page, usually it is layout or JS which are loaded by default issue, I document view you might need to preload/wait for something else to complete first.

@ValerasNarbutas 

Thank you so much for your reply! Unfortunatelly, even if I attach the extension to bottom placeholder it doesn't fix the issue. I worry it has something to do with the Documents tab itself. I feel like the error triggers before my code is even loaded and prevents it from beeing executed (since if I am already on Documents tab and refresh the page, the extension works).

Regards,

Iwo