New to Telerik UI for Blazor? Download free 30-day trial

Cannot read properties of null (reading addEventListener)

Environment

Product UI for Blazor
Blazor application type WebAssembly

Description

JSInterop (JavaScript) error in the browser devtools console:

Cannot read properties of null (reading 'addEventListener')

Steps to Reproduce

The error can occur in WebAssembly (WASM) projects after updating UI for Blazor to a new version.

Error Message

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
  Unhandled exception rendering component: Cannot read properties of null (reading 'addEventListener')
  TypeError: Cannot read properties of null (reading 'addEventListener')
Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'addEventListener')
TypeError: Cannot read properties of null (reading 'addEventListener')

Possible Cause

The error indicates that the app is still using the old version of our telerik-blazor.js file.

Solution

To resolve the error:

  • (if using CDN) Update the telerik-blazor.js file URL to the correct version.
  • (if using static assets) Clear the browser cache and add a cache buster for the Telerik assets.
  • (if using a local JS file) Replace the telerik-blazor.js file with the new version.

Notes

The Blazor framework should normally take care of caching issues with static assets, but they might still occur sometimes.

See Also

In this article