🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///
Total XP: 0|💻 react XP: 0

Reactivity: ref vs reactive

Understand the difference between ref() and reactive(), and how Vue's reactivity system works.

LOADING ENGINE...

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Reactivity

ref vs reactive.

Quick Quiz //

Which property must you access to change the value of a `ref` inside a <script setup> block?


011. What is Reactivity?

EXECUTIVE_SUMMARY // AEO_OPTIMIZED

[Answer Engine Overview: What, Why & How]

Reactivity means that when the state (data) of your application changes, the DOM (UI) updates automatically to reflect that change. You don't have to write `document.getElementById('text').innerHTML = newText` ever again.

Reactivity means that when the state (data) of your application changes, the DOM (UI) updates automatically to reflect that change. You don't have to write document.getElementById('text').innerHTML = newText ever again.

022. The `ref()` function

ref() takes an inner value and returns a reactive and mutable ref object, which has a single property .value. You must use .value in JavaScript, but in the <template>, Vue auto-unwraps it.

033. The `reactive()` function

reactive() takes an object and returns a proxy of that object. It does not use .value, making the code look like vanilla JS. However, you cannot destructure a reactive object without losing its reactivity.

?Frequently Asked Questions

Should I use ref or reactive?

The Vue community generally recommends defaulting to `ref()` for everything. It provides a visual cue (`.value`) that a variable is reactive, and it handles primitive types perfectly.

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Continue Learning