SIGN IN SIGN UP

Login to your account

Username or Email *
Password *
Remember Me
LWC Progress | ( Lessons)

Lesson: 31 | Communicate from Child to Parent


Child Component:


Parent Component:

In the child component, we're creating a lightning-button element and attaching a click event handler that fires a custom event named childbuttonclick.

In the parent component, we're including the child component and binding the onchildbuttonclick event to the handleChildButtonClick() method. When the child button is clicked, the handleChildButtonClick() method is called and sets a boolean variable to true. This variable is used to conditionally render a paragraph element that says "The child button was clicked."

To use this example, create two new LWC components named childComponent and parentComponent, and copy and paste the corresponding HTML and JavaScript code into the appropriate files. Then, run the application and open the parent component to see the child button. Click the button to see the paragraph element appear that indicates that the child button was clicked.


Prev You need to login to have access to the quizzes. Next

Mastered by 8 users.

Lightning Web Components

A. Component Reference (27 lessons)
B. Lightning Web Components | Utilities (11 lessons)
C. Lightning Web Component Guide (41 lessons)
D. Java Script Methods for LWC (23 lessons)
E. HTML (18 lessons)
Go to top