---
schema_version: "1"
id: 44dfac0112c74d60752ff31f87e4a03221b429e231267447d56309b03e6cbad2
title: Handle Component Event of Instantiated Component
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/events/events-component-handling-child.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/events-component-handling-child.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 788caacc2a5dcd5df1b227bb06349af01642db0229d4826b341f68fd82be7234
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# Handle Component Event of Instantiated Component

A parent component can set a handler action when it instantiates a child component in its markup.

Let’s a look at an example. `c:child` registers that it may fire a `sampleComponentEvent` event by using `<aura:registerEvent>` in its markup.

```nolang
<!-- c:child -->
<aura:component>
    <aura:registerEvent name="sampleComponentEvent" type="c:compEvent"/>
</aura:component>
```

`c:parent` sets a handler for this event when it instantiates `c:child` in its markup.

```nolang
<!-- parent.cmp -->
<aura:component>
    <c:child sampleComponentEvent="{!c.handleChildEvent}"/>
</aura:component>
```

Note how `c:parent` uses the following syntax to set a handler for the `sampleComponentEvent` event fired by `c:child`.

```nolang
<c:child sampleComponentEvent="{!c.handleChildEvent}"/>
```

The syntax looks similar to how you set an attribute called `sampleComponentEvent`. However, in this case, `sampleComponentEvent` isn’t an attribute. `sampleComponentEvent` matches the event name declared in `c:child`.

```nolang
<aura:registerEvent name="sampleComponentEvent" type="c:compEvent"/>
```

The preceding syntax is a convenient shortcut for the normal way that a component declares a handler for an event. The parent component can only use this syntax to handle events from a direct descendent. If you want to be more explicit in `c:parent` that you’re handling an event, or if the event might be fired by a component further down the component hierarchy, use an `<aura:handler>` tag instead of declaring the handler within the `<c:child>` tag.

```nolang
<!-- parent.cmp -->
<aura:component>
    <aura:handler name="sampleComponentEvent" event="c:compEvent"
      action="{!c.handleSampleEvent}"/>
    <c:child />
</aura:component>
```

The two versions of `c:parent` markup behave the same. However, using `<aura:handler>` makes it more obvious that you’re handling a `sampleComponentEvent` event.

**See Also**  


-   [Component Handling Its Own Event](https://developer.salesforce.com/docs/platform/aura-platform/guide/events-component-handling-itself.md)
-   [Handling Bubbled or Captured Component Events](https://developer.salesforce.com/docs/platform/aura-platform/guide/events-component-bubbling.md)

