The Power of Vue 3 Function Refs - Part 1
Video Statistics and Information
Channel: Alex Vipond
Views: 1,539
Rating: undefined out of 5
Keywords:
Id: EiqwYep8QEA
Channel Id: undefined
Length: 12min 28sec (748 seconds)
Published: Wed Oct 27 2021
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Really interesting and fascinating pattern!
Good to know about this.
But I'd rather use a parameter. Template refs are already obscure enough.
Great video, I learned something new :-)
With this pattern, is it somehow possible to use multiple "hooks"? For instance, useDimension('width'), useAnimate('wiggle'), useXXX()?
It seems like it is only possible to use one "hook" because the template element has just one :ref="element" to assign it to an element, right?
Good pattern, thanks.
Since you are using typescript i would recommend using strongly type version.
const element = ref<HTMLElement>();
or even better
const element = ref<HTMLDivElement>();
This is pretty cool
Well done video!
Although I found by the time we were getting to function refs that it was far too much magic.
It's not obvious how the element ref is being passed to the Observer to use.
This is neat. Although I agree with other poster it probably is easier to let consumers pass in the element ref. Easier if multiple composition functions would use the same ref too. Thanks for the video OP. It was clear and well explained!
I am confused why you used shallowRef?
It seems to me it causes nothing but an in-convivence of having to use .value with it. Since it becomes scoped variable for your lambda functions it will be alive till your component destroyed.
You said you like it but it's basically saying "i like wasting cpu time to do something not needed"