---
page_title: Managing Component Lifecycle
product: ClickToPay
page_source: https://juspay.io/sea/docs/clicktopay/docs/how-to-integrate/managing-component-lifecycle
llms_txt: https://juspay.io/sea/docs/llms.txt
product_llms_txt: https://juspay.io/sea/docs/clicktopay/llms.txt
---


# **Managing Component Lifecycle in ClickToPayWidget** 




### **What is** cleanupMountedApp function?



The cleanupMountedApp function is a crucial utility for managing component lifecycle and preventing memory leaks in the ClickToPayWidget implementation.


#### javascript Code Snippet:

```javascript
const cleanupComponent = (elem: HTMLElement) => {
// Framework-specific cleanup logic
// Example: React.unmountComponentAtNode(elem)
// Example: Vue app.unmount()
// Example: Angular - destroy component
}
```



#### **Purpose** 



* Ensures proper cleanup of mounted components
* Prevents memory leaks during re-renders
* Manages component lifecycle across render function calls

---

## See Also

- [Customise UI/UX](https://juspay.io/sea/docs/clicktopay/docs/how-to-integrate/customise-uiux)
- [Testing & Validation](https://juspay.io/sea/docs/clicktopay/docs/how-to-integrate/testing--validation)
