# Explain the LWC lifecycle hooks and the order in which they fire for a parent and child component.

**Topic:** Lwc · **Difficulty:** Medium · **Tags:** lwc, lifecycle

Read it on the site: https://www.forcechallenges.com/interview-questions/explain-the-lwc-lifecycle-hooks-and-the-order-in-which-they-fire-for-a-parent-and-child-component

## Answer

**Hooks:** `constructor()`, `connectedCallback()`, `render()`, `renderedCallback()`, `disconnectedCallback()`, `errorCallback(error, stack)`.

**Order when a parent contains a child:**
1. Parent `constructor`
2. Parent `connectedCallback`
3. Parent `render`
4. Child `constructor`
5. Child `connectedCallback`
6. Child `render`
7. Child `renderedCallback`
8. Parent `renderedCallback`

**Notes:**
- Call `super()` first in the constructor; don't access attributes or children there.
- `connectedCallback` fires when inserted into the DOM; use it to fetch data or subscribe.
- `renderedCallback` fires after every render, so guard one-time logic with a flag.
- `disconnectedCallback` is for cleanup (unsubscribe, remove listeners).
- `errorCallback` catches errors from child components in the lifecycle.

---
Source: ForceChallenges · last updated 2026-10-21
