DEV Community

loading...

Do you know these 5 things about Vue Lifecycle Hooks?

Atharva Sharma
Frontend Engineer. Keeping up my promise of making people-pleasing user experiences! I work remotely, love open source and all things Vue ❤
・1 min read
  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!

Discussion (0)