DEV Community

Atharva Sharma
Atharva Sharma

Posted on

Do you know these 5 things about Vue Lifecycle Hooks?

  1. Vue Lifecycle Hooks are an example of the Template Method Design Pattern.

  2. In the case of SSR, only the creation hooks are run on the server-side, all other hooks are run client-side.

  3. Vue has an errorCaptured() hook and contrary to what you might believe, it does not capture all the errors thrown inside the component. Setting up a global error handler is suggested.

  4. You can do programmatic lifecycle hook registration using $on or $once and pre-pending the hook name with hook:. Similarly, you can also listen to lifecycle hooks from children components.

  5. There is a significant delay between the created() and the mounted() hook.

I cover all the above-mentioned points and more in my talk here.

Alt Text

Happy Coding!

Top comments (0)