View profile

Weekly Vue News - #57 - Typing Template Refs With TypeScript

Michael Hoffmann (Mokkapps)
Michael Hoffmann (Mokkapps)
Hi πŸ‘‹
I’m busy working on my code snippet tool, no time for more introductory words πŸ€ͺπŸ§‘πŸ»β€πŸ’»
Have a great week β˜€οΈ

Vue Tip: Typing Template Refs With TypeScript
Template refs only exist after the component is mounted. Thus, it’s necessary to type template refs with a union type that includes the DOM element type as well as null:
The initial ref value is null until the component is mounted or if the v-if directive unmounts the element. Therefore, we use optional chaining to access textareaRef.value.
Quick Vue Tip
A quick Vue tip that can be used to improve the UX in forms.
The following code automatically puts focus on the next element in the form after pressing β€œEnter” key:
Curated Vue Content
Quote of the Week
Curated Web Development Content
Did you enjoy this issue? Yes No
Michael Hoffmann (Mokkapps)
Michael Hoffmann (Mokkapps) @mokkapps

Hi πŸ‘‹

My name is Michael Hoffmann and I'm a Senior Frontend Developer, Freelancer and Blogger.

I focus on Vue.js, JavaScript, TypeScript and Spring Boot. Occasionally I also give career & freelancer advice.

My weekly emails reflect this preference.

In order to unsubscribe, click here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Created with Revue by Twitter.
Holzapfelkreuther Straße 19, 81375 Munich, Germany