No video

Avoid losing Reactivity in your Vue Application

  Рет қаралды 6,979

Alexander Lichter

Alexander Lichter

Күн бұрын

Пікірлер: 79
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Like if you ever "lost" reactivity!
@Kingside88
@Kingside88 6 ай бұрын
I really like your videos because they are close to real life problems. Another big topic is avoiding losing reactivity with arrays.
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Thank you so much 🙏 Good point. Will write this down for another video! 👌
@xyronaldo
@xyronaldo 4 ай бұрын
The timing of this video is crazy. I was literally wrapping a prop in a ref and was wondering why my code was not behaving correctly. This video explanation was really helpful. Thank you for creating such an informative short video.
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
That is indeed great timing 👏🏻 Glad it helped!
@alimaher1
@alimaher1 5 ай бұрын
When the video came out, I watched and said to myself 'meh, it's a rare case'. Here coming back after spending more than an hour debugging my code. What a life haha! Thanks, Alexander!
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
Oh wow! Sometimes coincidence is too real 😆 Glad it helped 👏🏻
@cheaterman49
@cheaterman49 3 ай бұрын
Wow, excellent video, some of this stuff can be really confusing and isn't (AFAIK) really explained in the docs either - at least not as a whole. It's also great that you make recommendations "in passing" such as "don't destructure props" - addressing common mistakes before they happen is a great idea :-). Really a must-watch video IMHO, thanks for making it :-)
@LiranTal
@LiranTal 6 ай бұрын
Thanks for explaining this very simply, Alexander. I especially liked all the different options because you've hit the different cases I personally used. Please keep up with this type of content. I appreciate it a lot!
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
Glad it was helpful Liran! 🙌🏻
@gabrielserejo8379
@gabrielserejo8379 6 ай бұрын
Thanks Alex, please keep it up! I see every single video
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Definitely will! Thanks for tuning in every time 🙏
@BricBracASMR
@BricBracASMR 6 ай бұрын
I'm French. Your content is so qualitative! Thank you so much!
@unseriousdev
@unseriousdev 6 ай бұрын
🥖🥖🥖
@BricBracASMR
@BricBracASMR 6 ай бұрын
@@unseriousdev oui oui baguette 😋
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Thank you for tuning in! Gald it helps 🙌✨
@mattfletcher7321
@mattfletcher7321 6 ай бұрын
Your tutorials are very good! Would you be able to create a tutorial for writing a composable that could accept a primitive, ref, or getter? Or at least a deep dive into how vueuse or the nuxt composables handle this scenario?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Thank you! Yes, absolutely. Noted down 👌
@ribl1000
@ribl1000 6 ай бұрын
high value videos -some of the best most consice vue/nuxt content out there
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
Thank you so much 🙏🏻
@virusblitz
@virusblitz 6 ай бұрын
Thanks covering this, love it when you show common pitfalls! Even with vue experience I keep making some of these :)
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You are welcome! Glad it is helpful 🙌
@jass__0
@jass__0 6 ай бұрын
After working on react for 2 years , now moving to vue and it just amazed me. But now react making huge change by bringing its compiler hope that it wont hurt vue. Xd :) Btw, Good content.
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
Glad to hear that the switch to Vue was fun to you 👍🏻 Thank you ☺️
@alexandros-markovits
@alexandros-markovits 6 ай бұрын
Nice tutorial! Also caution for times that objects are being passed in a component, the reactivity mechanism can end up being based on value by reference. More examples and best practices of such cases could be interesting.
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Good point! It is general JS behavior but can still shoot you in the foot 🙈
@valacshiro378
@valacshiro378 6 ай бұрын
Thabk you this solved my problem. Realle good videos, keep it going this ir helpful in many ways 😊😊
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Awesome! Happy to hear they help 🙏
@alibahrami6810
@alibahrami6810 5 ай бұрын
I must say, awesome content! keep going great, Alexander!
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
Thanks, will do for sure! 🔥
@mattickx
@mattickx 6 ай бұрын
Is there any overhead if we would use toRefs() compared of toRef() ? I do prefer using toRefs() and destructing that result. But I wonder if there is overhead due to it parsing all props instead just the ones you want to make reactive. Or is this negligible?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Nah, toRefs is fine as long as you don’t have optional values. Then, restructuring might not work as expected 😊
@prishanf
@prishanf 3 ай бұрын
Hey Alex thanks a lot the great video. I’m still confused about what is the difference between props.title vs ()=> props.title
@reneeschke
@reneeschke 6 ай бұрын
I didn't know props is "reactive()" under the hood, nice! I'm surprised you didn't mention making a computed of title in the component. What's your stand here? It works, but probably not recommended?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Yeah, `computed` would be my go-to solution here as props are read-only anyway!
@reneeschke
@reneeschke 6 ай бұрын
@@TheAlexLichter why didnt u include the computed workflow in the video, then? just curious. you mean props are read only, right? refs can be changed? or am I crazy now 😂
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
Good question. Should've shown it too as an option, even though computed has a slight overhead (because it adds a dependency check) Yup, you are right - Updated my comment 😂
@DeepStreamBits
@DeepStreamBits 6 ай бұрын
Would a computed() value work the same as toRef()?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Yes, absolutely! And that'd also be my "go to" version when dealing with props or `reactive` values - especially as props are read-only anyway 👌
@youhan96
@youhan96 6 ай бұрын
Great explanation Alex! Made complete sense!
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Glad it was helpful! 🙏🏻
@ngetichishmael
@ngetichishmael 6 ай бұрын
This solves a lot of my problems 😂.
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Perfect 🙌
@vuenice
@vuenice 6 ай бұрын
Which title will be considered in template, props.titile or toRef(...)
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
The more explicit one (so const title > props.title) in the template
@karshten9218
@karshten9218 4 ай бұрын
Thanks a lot
@top10acousticshowslist77
@top10acousticshowslist77 5 ай бұрын
nice information not many people talk about this simple but important concept.♥♥♥
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
Glad you think so!
@nines_99
@nines_99 6 ай бұрын
probably i should read docs, but the obvious question is: what’s the difference between computed and toRef? why didn’t you use computed? and instead used toRef?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Computed would be my go-to for props. When having other reactives, toRef allows to sync between the values in both ways!
@nines_99
@nines_99 6 ай бұрын
@@TheAlexLichter ooh, i didn’t know that, thank you!
@unseriousdev
@unseriousdev 6 ай бұрын
Thanks, Alex 💚
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You are welcome! 👏
@yunusemrefersiz2848
@yunusemrefersiz2848 Ай бұрын
An Other great video ty Alex
@TheAlexLichter
@TheAlexLichter Ай бұрын
Thank you! 🙏
@hassankadhim5465
@hassankadhim5465 6 ай бұрын
🔥🔥
@Gaijin101
@Gaijin101 5 ай бұрын
Wonder if we ever gonna get a simpler ref vs reactive | useFetch vs $fetch. Its not very intuitive for most beginners.
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
Great idea Damian! Will put it on the list 👌
@Like_a_lion_979
@Like_a_lion_979 6 ай бұрын
Thank for the video, really useful. I wonder is there a way to use somehow toRefs to not lose reactivity?
@JiveOff
@JiveOff 6 ай бұрын
From experience, toRefs can be used with the output of defineProps, which then would make all props reactive if you use the output of toRefs.
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You are welcome! With toRefs, you won't lose the reactivity (as shown) ✔
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
toRef is useful for *optional* props (which are not covered via toRefs if they don't exist)!
@freekeys
@freekeys 2 ай бұрын
Exactly.... We shouldn't destructuring the props 💯, i used to do in my initial days🤦😂
@TheAlexLichter
@TheAlexLichter 2 ай бұрын
And you will be able to again in Vue 3.5 with the (in 3.4 experimental) props destructuring feature 👀
@freekeys
@freekeys 2 ай бұрын
@@TheAlexLichter so props destructuring won't lose the reactivity in vue 3.5 feature?🤔
@TheAlexLichter
@TheAlexLichter 2 ай бұрын
@freekeys yup! Check out the RFC @ github.com/vuejs/rfcs/discussions/502
@freekeys
@freekeys 2 ай бұрын
@@TheAlexLichter so pinia would also do it, current i need to use storeToRef in pinia. 🤦😂
@TheAlexLichter
@TheAlexLichter 2 ай бұрын
I still would go for storeToRefs because you get refs, not „reactive“
@kirayamato6128
@kirayamato6128 6 ай бұрын
auto import is not quite good. other devs will have a headache debugging or reading the code.
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
I'd argue that it is the opposite. For me, importing ref/computed/... all the time even though it is obvious that it comes from Vue creates more noise in the code. And because TS intellisense + "go to" still works, I can easily check where things come from if needed. But you can also make it work without auto imports if you prefer it 😊
@ricko13
@ricko13 6 ай бұрын
the .value thing is so annoying sometimes :/
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
I actually think it is useful When using TS the IDE should autocomplete it 🙌🏻 And then you know if the value you deal with is reactive or not 👌🏻
@user-qu6vy8ub1g
@user-qu6vy8ub1g 3 ай бұрын
I think you're left-handed 5:10
@TheAlexLichter
@TheAlexLichter 3 ай бұрын
I think you are right 😁
Dynamic Components in Vue
14:30
Alexander Lichter
Рет қаралды 7 М.
useAsyncData vs. useFetch 🤯
15:20
Alexander Lichter
Рет қаралды 9 М.
ISSEI & yellow girl 💛
00:33
ISSEI / いっせい
Рет қаралды 24 МЛН
SPONGEBOB POWER-UPS IN BRAWL STARS!!!
08:35
Brawl Stars
Рет қаралды 17 МЛН
DejaVue #E001 - The Need for Server-Side Rendering (SSR)
35:45
You are using useFetch WRONG! (I hope you don't)
11:14
Alexander Lichter
Рет қаралды 26 М.
Svelte 5 Runes Demystified (1/4) - Signal Reactivity Basics
28:15
Peter Makes Websites Ltd
Рет қаралды 4,1 М.
3 Ways to Avoid Prop Drilling in Vue/React
9:34
Lachlan Miller
Рет қаралды 4,5 М.
It's time for change, it's time for Linux.
10:53
DankPods
Рет қаралды 274 М.
Why you should use useState()
17:57
Alexander Lichter
Рет қаралды 16 М.
Why didn't the Angular team just use RxJS instead of Signals?
8:15
Joshua Morony
Рет қаралды 92 М.
Reactivity Explained
7:29
Awesome
Рет қаралды 28 М.
DHH - Ruby on Rails, 37signals, and the future of web development
1:09:57
How to use Nuxt Layers to encapsulate your code
17:08
Alexander Lichter
Рет қаралды 8 М.
ISSEI & yellow girl 💛
00:33
ISSEI / いっせい
Рет қаралды 24 МЛН