We are using among other components the TreeView component for showing an hierarchical view of an organization and that works fine in most cases, there is however an issue that happens when the users are quick to navigate between views and we get an error:
Unhandled exception rendering component: Cannot read property 'addEventListener' of null
TypeError: Cannot read property 'addEventListener' of null
After some investigation of the code and how the TreeView works we can see that this probably happens due to that the OnAfterRenderAsync of the TreeView runs InitTreeView which calls JSInterop to set event handling for example:
this.options.draggable && this.createDraggable()
but since this is run in OnAfterRenderAsync it may happen even after the component is disposed and removed from the DOM so the elements are no longer available and the error occurs.
Is this a known issue and is there a way to handle it?