<commit_before>+++
date = "2020-11-15T11:20:20+02:00"
title = "watch vs. watchEffect when to use what with Vue.js"
description = "Learn about the differences between watch and watchEffect hooks, when to use what, and how watchEffect is similar to computed."
intro = "When I first studied the new Composition API, I was confused that there are two watch hooks: `watch()` and `watchEffect()`. From the documentation alone, it was not immediately apparent to me what's the difference..."
draft = false
categories = ["Development"]
tags = ["JavaScript", "Vue"]
+++

When I first studied the new Composition API, I was confused that there are two watch hooks: `watch()` and `watchEffect()`. From the documentation alone, it was not immediately apparent to me what's the difference.

## The Difference Between `watch` and `watchEffect`

Assuming you already know how `watch()` works with the Options API, it is easy to understand how the `watch()` hook works.

> The `watch()` hook works like the `watch` option.<commit_msg>Add link to official Vue docs<commit_after>+++
date = "2020-11-15T11:20:20+02:00"
title = "watch vs. watchEffect when to use what with Vue.js"
description = "Learn about the differences between watch and watchEffect hooks, when to use what, and how watchEffect is similar to computed."
intro = "When I first studied the new Composition API, I was confused that there are two watch hooks: `watch()` and `watchEffect()`. From the documentation alone, it was not immediately apparent to me what's the difference..."
draft = false
categories = ["Development"]
tags = ["JavaScript", "Vue"]
+++

When I first studied the new Composition API, I was confused that there are two watch hooks: `watch()` and `watchEffect()`. From [the documentation](https://v3.vuejs.org/guide/reactivity-computed-watchers.html#watcheffect) alone, it was not immediately apparent to me what's the difference.

## The Difference Between `watch` and `watchEffect`

Assuming you already know how `watch()` works with the Options API, it is easy to understand how the `watch()` hook works.

> The `watch()` hook works like the `watch` option.
{'fraction_non_alphanumeric': 0.10103383458646617, 'fraction_numerical': 0.01738721804511278, 'mean_word_length': 4.96358543417367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1371253', 'n_tokens_mistral': 606, 'n_tokens_neox': 552, 'n_words': 294}