Complete the code to import the Vue Composition API function needed to create a reactive reference.
import { [1] } from 'vue';
The ref function creates a reactive reference to a value, which is essential for composables.
Complete the code to define a composable function that returns a reactive count.
export function useCounter() {
const count = [1](0);
return { count };
}Inside a composable, ref(0) creates a reactive count starting at zero.
Fix the error in the composable by completing the missing reactive function.
import { [1] } from 'vue'; export function useToggle() { const state = [1](false); function toggle() { state.value = !state.value; } return { state, toggle }; }
The ref function is needed to create a reactive boolean state that can be toggled.
Fill both blanks to create a composable that returns a reactive message and a function to update it.
import { [1] } from 'vue'; export function useMessage() { const message = [2]('Hello'); function update(newMsg) { message.value = newMsg; } return { message, update }; }
Both importing and using ref is correct here to create a reactive string message.
Fill all three blanks to create a composable that tracks a number and provides increment and reset functions.
import { [1] } from 'vue'; export function useNumberTracker() { const number = [2](0); function increment() { number.value += 1; } function reset() { number.value = [3]; } return { number, increment, reset }; }
Use ref to create a reactive number starting at zero, and reset sets it back to 0.