0 day streak
javascript / beginner
Snippet

Reactive Objects with reactive()

The reactive() function creates a deep reactive proxy of an object. Unlike ref(), you do not need to use .value to access properties in your script.

snippet.js
javascript
1
2
3
4
5
6
import { reactive } from 'vue';
const state = reactive({
count: 0,
user: 'Alex'
});
vue
Breakdown
1
import { reactive } from 'vue';
Imports the reactive function from the Vue core library.
2
const state = reactive({
Initializes a reactive state object.
3
count: 0,
A numeric property within the reactive object.