fire a child Lightning Web Component method from Parent LWC

In last two blogs, We have learnt to communicate and pass data between parent to child and child to parent Lightning Web Component. This time we are going to learn to call methods on child components from parent Lightning Web Component.


There are two components:- parentWebComponent and childWebComponent. The child component has been called in parent component. The parent also have a button which fires an method defined in child component.

Before going for Code, You should know these things:-

  • To expose a public method, decorate it with @api.
  • Public methods are part of a component’s API.
  • To communicate down the containment hierarchy, owner and parent components can call JavaScript methods on child components.


We just have an property shown with some static text in html markup. The property is defined in js file and it is reactive. Hence it will be re-render when the value gets changed.

  The Value is : {value}


We have a public method defined which can be called from owner or parent component.

import { LightningElement, track,api } from "lwc";

export default class ChildWebComponent extends LightningElement {
  @track value=100; //reactive in nature 
  //public method
  @api handleValueChange() {


We are not exposing this to any page type as it will be called in parent web component.

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="" fqn="childWebComponent">


It consist of child component and a button with onclick handler which will call the method defined in child component.

  <!--calling child web component here-->
  <lightning-button variant="brand" label="Submit" onclick={handleClick}>


The onclick handler will call the child component method by using querySelector.

import { LightningElement } from "lwc";

export default class ParentWebComponent extends LightningElement {
  handleClick() {
    //firing an child method


This file defines where you can use the component in Salesforce. Here, we have exposed it to record, App page and home page.

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="" fqn="ParentWebComponent">

Demo(Call Methods on Child Components)

As soon as user clicks on button, child method which is being called from parent component changes the value to 200.

Demo call an child method in Lightning Web Component

One comment

Leave a Reply