Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Uncaught TypeError: Cannot read property 'apply' of undefined when calling function on parent LWC

Asked by Bhaanumati Shukla Jul 6, 2021 1.1K views 3 answers
Share

About this question

 I have a LWC I am embedding in a flow. The LWC embeds another LWC as a component. (its basically this one: https://live.playg.app/play/custom-carousel-with-lwc ) On the parent LWC my onclick event fires fine. But when I click on the embedded one it gives this error: Uncaught TypeError: Cannot read property 'apply' of undefined throws at Any ideas what I am doing wrong? Shouldn't a child LWC be able to invoke a parent function no problem?

my code


Your answer

3 Answers

Taylo Elle

Answered on Dec 10, 2024

Use Custom Events: Instead of directly calling the parent function, emit a custom event from the child LWC. The parent can listen for this event and then call the desired function. This is the Build Now GG recommended approach in LWC for communication between components.

Was this helpful?

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.