cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mrQ
Post Patron
Post Patron

PCF Component Tutorial issue

Dear community,

 

I'm starting out with PCF components and following the official tutorial of Microsoft.

However, I'm stuck with an error I'm getting after running `npm run build`, and I can't seem to solve it. The error message I receive is 

 

EventListener is not defined

 

 and I was following the tutorial step by step.

Can someone point me in the right direction? I guess it's an easy fix for you guys.

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
deepakMehta
Regular Visitor

Follow below steps:

1. remove or comment variable declaration buttonClickHandler i.e. 

    // private buttonClickHandler: EventListener;
2. remove or comment the statement in methhod "init".  
 //this.buttonClickHandler = this.buttonClick.bind(this);
and add statement 
  this.buttonClick = this.buttonClick.bind(this);
3. Update method "init" to add event listener instead with variable this.buttonClickHandler to this.buttonClick  i.e. 
button.addEventListener("click", this.buttonClick);
4. update method "destroy" to remove event listener i.e. 
this.container.querySelector("button")!.removeEventListener("click", this.buttonClick);
 
It works for me with above changes. 
Thanks
 

View solution in original post

2 REPLIES 2
deepakMehta
Regular Visitor

Follow below steps:

1. remove or comment variable declaration buttonClickHandler i.e. 

    // private buttonClickHandler: EventListener;
2. remove or comment the statement in methhod "init".  
 //this.buttonClickHandler = this.buttonClick.bind(this);
and add statement 
  this.buttonClick = this.buttonClick.bind(this);
3. Update method "init" to add event listener instead with variable this.buttonClickHandler to this.buttonClick  i.e. 
button.addEventListener("click", this.buttonClick);
4. update method "destroy" to remove event listener i.e. 
this.container.querySelector("button")!.removeEventListener("click", this.buttonClick);
 
It works for me with above changes. 
Thanks
 
mrQ
Post Patron
Post Patron

Hi @deepakMehta 

You're a rockstar! That works, thank you. 

Now we just need to get MS to fix it on their learning platform 😁

 

Thanks again! I appreciate it.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (4,201)