Skip to content

Latest commit

 

History

History
73 lines (54 loc) · 2.32 KB

common-cannot-read-properties-of-null-reading-addeventlistener.md

File metadata and controls

73 lines (54 loc) · 2.32 KB
title description type page_title slug position tags ticketid res_type
Cannot read properties of null (reading addEventListener)
How to resolve JavaScript JSInterop error about addEventListener in Blazor WebAssembly applications.
troubleshooting
Cannot read properties of null (reading addEventListener)
common-kb-cannot-read-properties-of-null-reading-addeventlistener
error, update, WASM, WebAssembly
1545248, 1550215, 1550371, 1552007
kb

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

````JS 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') ````
````JS 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

  • Telerik UI for Blazor version upgrade steps
  • Troubleshooting JavaScript Errors
  • Fix styling issues after component version update