question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'addEventListener' of undefined when calling enableDragSelection

See original GitHub issue

Hello,

I am using wavesurfer within a react app, and I came across a strange issue. I’m using the Regions plugin and I need to do enableDragSelection. So once the wavesurfer is ready and it fires the ready event, I call wavesurfer.enableDragSelection({});. This works just fine when I am running the app locally, but as soon as I make a deploy on Heroku, I get this error instead.

Uncaught TypeError: Cannot read property 'addEventListener' of undefined
    at o.value (regions.js:742)
    at o.enableDragSelection (regions.js:607)

Any help really appreciated! 😃

Wavesurfer.js version(s): 2.1.1

Browser version(s): Chrome v70

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
Bran1304commented, Dec 4, 2018

Thanks for all your help guys, I resolved it by checking the isReady value in wavesurfer.regions.wavesurfer like so:

onReady(wavesurfer) {
    if (!wavesurfer.regions.wavesurfer.isReady) {
      setTimeout(() => this.onReady(wavesurfer), 1000)
      return
    }

    wavesurfer.enableDragSelection({});
}

I might look into adding that event @thijstriemstra when I get some free time this weekend 👍

0reactions
shobeescommented, Jan 25, 2019

I am using Wavesurfer in react app . It works . I save the regions in server . I want to add the saved region when the annotate load …

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Cannot read property 'addEventListener' of null
I think the easiest approach would be to just check that el is not null before adding an event listener: var el =...
Read more >
Uncaught TypeError cannot read property ...
In JavaScript, a very common error is the Uncaught TypeError Cannot read property 'addeventlistener' of null. This error occurs when JavaScript is not...
Read more >
[SOLVED] Cannot Read Property 'addEventListener' of Null ...
The “cannot read property 'addEventListener' of null” error occurs in JavaScript when you try to call the addEventListener() method on an ...
Read more >
Explaining and Solving "Cannot read property ... - YouTube
Your browser can't play this video. ... need to save and refresh Cannot read property addEventListener of undefined - Variable declared but ...
Read more >
How to fix "TypeError: Cannot read properties of ... - YouTube
JS Casts 12 - How to fix " TypeError: Cannot read properties of null ( reading addEventListener )" in JavaScript.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found