Vue · Middle · Question 30 of 75

What problem does nextTick solve here?

showInput.value = true;
await nextTick();
inputRef.value.focus();

Explanation

State changes are batched; the DOM updates later in the same tick. Without nextTick, inputRef.value is still null.

Further reading

Problem with a question

Vue · Middle · question 30

Test yourself

Take the Vue · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz