---
schema_version: "1"
id: f028dffd99ebd08caf5e4289f4a94d17f42a1ae0dd6cfe94125b8c8a9cf79687
title: Events Anti-Patterns
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/events/events-anti-patterns.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/events-anti-patterns.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 8502daa5cfd9d2dd5275255697a102ec03a064cc291ae9d32e4740ab7ce4c12a
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# Events Anti-Patterns

These are some anti-patterns that you should avoid when using events.

## Don't Fire an Event in a Renderer

Firing an event in a renderer can cause an infinite rendering loop.

**Don’t do this!**

```javascript
afterRender: function(cmp, helper) {
    this.superAfterRender();
    $A.get("e.myns:mycmp").fire();
}
```

Instead, use the `init` hook to run a controller action after component construction but before rendering. Add this code to your component:

```nolang
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
```

For more details, see .[Invoking Actions on Component Initialization](https://developer.salesforce.com/docs/platform/aura-platform/js-cb/js-cb-init-handler.md).

## Don’t Use `onclick` and `ontouchend` Events

You can’t use different actions for `onclick` and `ontouchend` events in a component. The framework translates touch-tap events into clicks and activates any `onclick` handlers that are present.

**See Also**  


-   [Create a Custom Renderer](https://developer.salesforce.com/docs/platform/aura-platform/js/js-renderers.md)
-   [Events Best Practices](https://developer.salesforce.com/docs/platform/aura-platform/guide/events-best-practices.md)

