From the course: Web Components and Modularization: Practical Approaches

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Life cycle

Life cycle

- [Instructor] Components have a lifecycle with hooks at strategic points throughout some of the phases. These life cycle phases are: initialization, where the properties and initial state for the component are sets, mounting, where the component is actually built and mounted onto the DOM tree, updating, where updates to the existing components in the DOM tree are done, and finally, unmounting, where the component is spun down and unmounted so removed from the DOM tree. When designing a component, it's important to think about what happens and when. For example, if you're introducing a new component at a specific point during the user experience, say a popup modal, or an info card, or something like that, you can use a hook like componentWillMounts and componentDidMounts to trigger specific actions at specific points. These hooks can then be used to fire additional events, to provide feedback to the user, to keep a log…

Contents