---
schema_version: "1"
id: 44c76fee1b1ccf6faa9b967f40a39e4cce09cf858248e905a69de5276034c909
title: removeMessageHandler()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/container/container-npm-removemessagehandler.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/container-npm-removemessagehandler.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 589744cb71a9ba89958bf3af47c17362821565fc20e6db4edecd5e301e1c4091
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# removeMessageHandler()

Unmounts the message-handling function.

When using React, it’s necessary to unmount functions to remove them from the DOM and perform necessary cleanup.

## Sample

Used within a JavaScript app uploaded as a static resource and referenced by `lightning:container`, this example unmounts a message handling function.

```javascript
componentWillUnmount() {
  LCC.removeMessageHandler(this.onMessage);
}
```

## Arguments

| Name                              | Type     | Description                                                      |
| --------------------------------- | -------- | ---------------------------------------------------------------- |
| `handler: (userMsg: any) => void` | function | The function that handles messages sent from the Aura component. |

## Response

None.
