nextTick in Vue

Vue interview exercise on Lifecycle & refs, difficulty 2 of 3. Solve it in the editor beside a worked example; the tests run the moment you do.

Write EditableTitle with a prop `title`: an <h2> with the title and a <button class="edit">. Clicking Edit replaces them with an <input> holding the title, focused (the input only exists after the next render: await nextTick() before focusing). Enter emits `save` with the trimmed input and leaves edit mode; Escape leaves edit mode without emitting.

Each exercise pairs a worked example with a twin problem to solve in a real editor; the tests run the moment you do. Progress is saved in your browser, and in your account if you sign in.

More Lifecycle & refs in Vue

All Vue exercises · Other languages and frameworks