0
0
Vueframework~10 mins

Shallow ref and shallow reactive in Vue - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a shallow reactive object in Vue.

Vue
import { [1] } from 'vue';

const state = [1]({ count: 0, nested: { value: 10 } });
Drag options to blanks, or click blank then click option'
Aref
Breactive
CshallowRef
DshallowReactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reactive' instead of 'shallowReactive' causes deep reactivity.
Using 'ref' creates a reactive reference, not an object.
Using 'shallowRef' creates a shallow reactive reference, not an object.
2fill in blank
medium

Complete the code to create a shallow ref in Vue.

Vue
import { [1] } from 'vue';

const count = [1](0);
Drag options to blanks, or click blank then click option'
AshallowRef
BshallowReactive
Creactive
Dref
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ref' creates a deep reactive reference.
Using 'reactive' is for objects, not refs.
Using 'shallowReactive' is for objects, not refs.
3fill in blank
hard

Fix the error in the code to correctly create a shallow reactive object.

Vue
import { [1] } from 'vue';

const data = [1]({ user: { name: 'Alice' } });
Drag options to blanks, or click blank then click option'
AshallowReactive
Breactive
CshallowRef
Dref
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving 'reactive' causes nested properties to be reactive.
Using 'ref' or 'shallowRef' is incorrect for objects.
4fill in blank
hard

Fill both blanks to create a shallow ref and access its value correctly.

Vue
import { [1] } from 'vue';

const count = [1](0);

console.log(count.[2]);
Drag options to blanks, or click blank then click option'
AshallowRef
Bvalue
Ccount
Dref
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ref' instead of 'shallowRef' changes reactivity depth.
Accessing the ref directly without '.value' causes errors.
5fill in blank
hard

Fill all three blanks to create a shallow reactive object and update a nested property.

Vue
import { [1] } from 'vue';

const state = [1]({ nested: { count: 0 } });

state.nested.[2] = 5;

console.log(state.nested.[3]);
Drag options to blanks, or click blank then click option'
AshallowReactive
Bcount
Dreactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reactive' instead of 'shallowReactive' changes reactivity depth.
Using different property names causes undefined errors.