New component patterns for Vue 3

Sdílet
Vložit
  • čas přidán 9. 07. 2024
  • Andy Li rates and reviews three new component patterns for Vue 3.
    Ready to master Vue.js? With weekly Vue js tutorials on the latest topics, and exclusive content with Evan You (the creator of Vue), Vue Mastery is the ultimate learning resource for Vue developers to level-up their skills. Watch more free Vuejs tutorials 👉 www.vuemastery.com/courses
    Get in touch 👉 team@vuemastery.com
    0:00 3 component patterns
    1:11 Hybrid Syntax
    7:36 Functional Syntax
    15:35 Script Setup Syntax
  • Věda a technologie

Komentáře • 57

  • @VueMastery
    @VueMastery  Před 2 lety +3

    FYI💡 We have an entire library of premium Vue courses for all skill levels filled with detailed explanations like this one. You can dive in here: buff.ly/3GptTTS

  • @DedicatedManagers
    @DedicatedManagers Před 2 lety +6

    Well done. Best video by this channel. More videos from Andy Li!

  • @Gepeto213
    @Gepeto213 Před 2 lety +5

    As I'm refactoring many components to script setup this video is very enlightening on the advantage to use it. A must watch video!

  • @brad7957
    @brad7957 Před 2 lety +4

    Thanks for this. I've been using Vue for about 3 years now and have been procrastinating learning the new APIs but it seems much simpler than I expected (thanks to your teaching skills, no doubt) :)

  • @henkspaaij7961
    @henkspaaij7961 Před 2 lety +2

    Very well articulated and explained. Thank you!

  • @gazisalahuddin8681
    @gazisalahuddin8681 Před 8 měsíci

    Thanks a lot. Loved it

  • @pranav7374
    @pranav7374 Před 2 lety

    Hey, @14:48 for defining default prop value we can further simplify by making use of '||' OR operator returning left operand if true or else right operand (default value) for eg:-
    count:_props.count || -1;

  • @vladshepeluk7442
    @vladshepeluk7442 Před rokem

    Hi! Thanks great job ❤ Is it possible to use context in setup syntax?

  • @nove1398
    @nove1398 Před 2 lety

    Finally am explanation on the who old change, this is very 😎

  • @jacobhassel5860
    @jacobhassel5860 Před 2 lety +3

    Great vid! Really excited about Vue 3 and using script setup with typescript. Unfortunately I can't migrate to Vue 3 until the libraries we use start supporting it, specifically Vuetify. It could be another year before we can upgrade 😢.

    • @cnikolov
      @cnikolov Před 2 lety +2

      vuetify its blocker for us too, but they save us soo much time that its worth to wait the bloody year :D

  • @VitorNeves
    @VitorNeves Před 2 lety

    I have a question about defining props using TS annotation. How can we use validator?

  • @edu.paixao
    @edu.paixao Před 2 lety

    18:23 it's so beautiful
    *interface* 😍

  • @tianqing9363
    @tianqing9363 Před 2 lety

    i am curious what software you used to create this video?

  • @RobertoMaurizzi
    @RobertoMaurizzi Před 2 lety

    Uuuh that was useful, thanks.
    I understood I'm using a functional component for a quite complex form rendering component I'm writing, but I was calling it "render function component" 😅 (and I already found out reactive variables don't work because changing them doesn't trigger render function execution, nice to have official confirmation :D)

  • @fluffyartdev
    @fluffyartdev Před 2 lety +3

    You can use default values while object destructuring..but setup looks rly promising except the thing that everything will be exposed (exported). That doesn't seem good

  • @x0r1k
    @x0r1k Před 2 lety +2

    Wow, didn't know about props with default in typescript

  • @mjmontes2653
    @mjmontes2653 Před rokem

    awesome 🤓

  • @magdasmircea4419
    @magdasmircea4419 Před 2 lety

    I have a question. Does options API gets tree shaked if not used, in the final build if webpacked is used?

    • @VueMastery
      @VueMastery  Před 2 lety

      No, because the Composition API is still relying on options. For example, you would still have to rely on the props option either way. Even with script setup, the final compiled code would still rely on the props option.

    • @mathe42
      @mathe42 Před 2 lety

      You can treeshake most of it away with some build time flag!

  • @vevan
    @vevan Před 2 lety +2

    I'm still love options api. the compsition api may do some things better, so we probably will switch to hybird components, but it's hard to convince me to use setup script.

  • @heyyy4987
    @heyyy4987 Před 2 lety

    There is a risk of vue macro for typescript Will blow it sometime?

  • @alvinindrap
    @alvinindrap Před 2 lety

    Why template need below in script setup?

    • @VueMastery
      @VueMastery  Před 2 lety +1

      It's purely for readability purposes. The idea is that the actions (variable declarations and function definitions) in script has to happen before the code in the template would make sense. Also, that's the convention you would see in the Vue docs.

    • @alvinindrap
      @alvinindrap Před 2 lety

      @@VueMastery Okay, Thank you

  • @justafreak15able
    @justafreak15able Před 2 lety

    How do you name a component in script setup?

    • @io-er1ex
      @io-er1ex Před 2 lety +1

      You can have more than one script tag e.g

      export default { name: 'ComponentName' };

    • @justafreak15able
      @justafreak15able Před 2 lety

      @@io-er1ex is that the only way?

    • @alvinindrap
      @alvinindrap Před 2 lety

      If I only import
      import ComponentName from '../component.vue'

    • @justafreak15able
      @justafreak15able Před 2 lety

      @@alvinindrap That’s not my question.

  • @LewizW
    @LewizW Před 2 lety

    looks like hooks from react?

    • @RR-zd5yt
      @RR-zd5yt Před 2 lety

      indeed it is

    • @fluffyartdev
      @fluffyartdev Před 2 lety

      There is a little difference, useEffect does almost all the work, but with vue you still have uccess to lifecycle, you always known that you have your window object in your onMounted hook

  • @abylaysanduzel5117
    @abylaysanduzel5117 Před 2 lety

    You really look like Kazakh)

  • @rush-rr
    @rush-rr Před 2 lety

    Функциональные компоненты жижа какая-то

  • @mahmoudalmontasser8369
    @mahmoudalmontasser8369 Před 2 lety +1

    Vue is turning into React 😂

  • @lualua5288
    @lualua5288 Před rokem

    clich

  • @zlatkoiliev8927
    @zlatkoiliev8927 Před 2 lety

    Basically, stealing ideas from React 😂

  • @cyberpunkdarren
    @cyberpunkdarren Před 2 lety +3

    Sadly vue 3 is a step backward in my opinion. All kinds of unecessary syntax. Deviates from the simple class model that made vue easy.

    • @YourEverydayDeveloper
      @YourEverydayDeveloper Před 2 lety +2

      same in my opinion. Too many possibilities to do the same thing and therefore a bigger learning curve.

    • @cyberpunkdarren
      @cyberpunkdarren Před 2 lety

      @@YourEverydayDeveloper its sad because simplicity was what made vue great. Now its too confusing. Too many chefs

    • @furkangokhasan8893
      @furkangokhasan8893 Před 2 lety +3

      Actually, vue is still vue. You can still use options api. But if you work on a big project, options api start to be very confusing. Vue needs the composition api.

    • @cyberpunkdarren
      @cyberpunkdarren Před 2 lety

      @@furkangokhasan8893 maybe in spirit but in practice all this "defineComponent" "ref" and "setup" is unecessary and breaks the whole semantics of MVC, classes, methods. I have very big ui projects and if you design it right, using events you dont need more api complexity.

    • @JonasEmanuel20
      @JonasEmanuel20 Před 2 lety +1

      I agree with you. If the Vue 3 had only a syntax for define the components the learning curve would be smaller and the apprenticeship less confuse.