Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Cannot read property '_blazorFilesById' of null error" with Blazor InputFile component

I've started getting this error from my Blazor WebAssembly app:

"Cannot read property '_blazorFilesById' of null error" with Blazor app

I'm assuming that's related to the InputFile component I'm using, which has been working fine.

I've tried restarting VS, clean & rebuilding, restarting IIS and killing Chrome all to no avail. What could be causing this?

like image 594
tomRedox Avatar asked Jan 30 '21 22:01

tomRedox


3 Answers

This turns out to be because I'd added conditional code to hide the InputFile component on the page. Doing that will cause the error as explained in this post on GitHub by BtbN:

Did you modify your page, so the InputFile element is not rendered anymore? It has to stay present, otherwise the browser cleans up any resources associated with it.

like image 125
tomRedox Avatar answered Oct 17 '22 17:10

tomRedox


I tried keeping the InputFile component inside a Div and conditionally (based on a bool @uploadingInProgress) hiding the Div (esp. during the upload progress) works perfectly

like image 3
Debraj Banerjee Avatar answered Oct 17 '22 16:10

Debraj Banerjee


this is happening because you are most likely calling StatehasChanged in the onchange function

like image 1
Tyrone Harding Avatar answered Oct 17 '22 17:10

Tyrone Harding