Vue.js Advanced Component Composition Patterns

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024

Комментарии • 66

  • @pranav854
    @pranav854 2 года назад +8

    Congratulations on the 100k, Erik!
    Great video. Would love to see some similar advanced Vue content in the future!

  • @Remeroska
    @Remeroska 2 года назад +18

    Be careful with the composition store. Having reactive values outside of the setup script lifecycle can lead to nightmarish memory leaks both in the browser and in the server (if you're working in an SSR environment). I strongly advise against it. Nuxt 3 useState approach (keyed reactive refs) is by far the safest and more correct approach.

    • @RicoHerwig
      @RicoHerwig 2 года назад +2

      That's an interesting topic! Do you, by chance, have a resource where I can read more about that?

    • @ProgramWithErik
      @ProgramWithErik  2 года назад

      Hey Thanks Matteo! I have not heard of that, but that makes sense. Perhaps using something like effect Scope, could be used to mitigate that problem... v3.vuejs.org/api/effect-scope.html#effectscope

    • @Remeroska
      @Remeroska 2 года назад +3

      @@ProgramWithErik it sure does. When you define refs/reactive values outside of setup they provide a function to have their effects disposed and garbage collected. If you don't dispose them correctly memory keeps going up every time you reload a page. I'll create a reproduction repository if you want, I have had this problem twice with two projects before understanding what was wrong 😅

    • @AEspinoRful
      @AEspinoRful 2 года назад +1

      @@Remeroska Do you know another solution besides using Nuxt 3?

    • @brunofunnie
      @brunofunnie Год назад +1

      And that's why StackOverflow doesn't allow (receive a lot of downvotes) when a comment like this appear. It creates a doubt on people minds, doesn't provide any proof of concept, put a lot of "facts" and just leave. When you do certain assumptions and advice people with phrases that contain a "don't do that" label is you obligation to show a least a POC showing the scenario, otherwise is just bollocks.

  • @LesCarbonaro
    @LesCarbonaro 2 года назад +10

    Slots are cool and all, but beyond one or two levels deep they become cumbersome. So to me the store pattern is the way to go here. jsx?? I don't think so... it's what turned me off of react and onto Vue in the first place, so not about to go down that route again. Informative tutorial, thank you.

    • @ProgramWithErik
      @ProgramWithErik  2 года назад

      Glad it helped~! Yeah, JSX isn't for everyone.

  • @brandonleichty
    @brandonleichty 2 года назад

    Congrats on reaching 100k developers! You're my #1 go-to Vue channel!

  • @LuckyStilet1
    @LuckyStilet1 2 года назад +2

    You could use

    • @ProgramWithErik
      @ProgramWithErik  2 года назад +2

      Interesting! I did not know that. I'll try that next time.

    • @whatsupbudbud
      @whatsupbudbud Год назад

      So it' s basically inline jsx?

  • @rotorink
    @rotorink 2 года назад +1

    nice! more tsx in vue? it’s a little more experimental & not as seamless as jsx in react, naturally, but vue with tsx fascinates me. there’s a couple good resources on how to work with the 2 but there’s really not a lot of content out there on it.

  • @graphicdesignandwebsolutio365
    @graphicdesignandwebsolutio365 2 года назад +1

    Definitely want a JSX vid

  • @danielwood2432
    @danielwood2432 2 года назад +4

    Would you create a video about how to render a component from async content? For example...think Wordpress style short-code. Loading a vue component from HTML that is loaded from an API call. I've always wonder if there was a way to do that. I assume using the render function would be needed.

    • @ProgramWithErik
      @ProgramWithErik  2 года назад +2

      Interesting, might be a fun topic to look at! Thanks I don't think I've ever done that. But I'm sure it could be done...

  • @rajikkali2381
    @rajikkali2381 2 года назад

    Global modals work great with the store pattern using an object that holds all state I want. I do it all the time and it’s infinitely customizable on the fly without limitation.

  • @artakan303
    @artakan303 2 года назад +2

    It looks cool at the beginning, but you kind of open the Pandora box with the issues, I speak about experiences. Issues when you want to use events, issues when you want to use Jest, etc, ....

    • @ProgramWithErik
      @ProgramWithErik  2 года назад

      That's a good point? Are you talking specifically about using JSX, or slots?

    • @artakan303
      @artakan303 2 года назад

      @@ProgramWithErik JSX is problematic (maybe it's because I still use Vue2, as Vuetify is not ready yet), slots are native to Vue, so there is not issues with them.

  • @DarylLegion
    @DarylLegion 2 года назад

    Thanks Erik, great tutorial! I just started to learn Vue and in the future I might use this.

  • @jitendra2510
    @jitendra2510 2 года назад +1

    I think it will be a great feature for updating Hybrid apps live, without pushing a real app update into the store.

  • @cesswhite
    @cesswhite 2 года назад +1

    Thank you Erik, amazing video

  • @rajikkali2381
    @rajikkali2381 2 года назад +1

    Never had to import mounted (onMounted) before… with Vue3 we write more code and it’s less readable.

  • @caiovinicius7871
    @caiovinicius7871 2 года назад

    The composition store way is magnific! I'll start to use it in my projects when necessary.

  • @edwardgwilson
    @edwardgwilson 2 года назад

    Off topic question... what theme are you using in VS Code?

  • @shanTwo
    @shanTwo 2 года назад +2

    Quasar ❤️

  • @arnesneyers2076
    @arnesneyers2076 2 года назад

    You are becoming my best friend! :)

  • @DedicatedManagers
    @DedicatedManagers 2 года назад

    At 6:24 why don’t you just export the store variable. Why do you need a function to call to retrieve the variable.

  • @gd9464
    @gd9464 2 года назад

    Hi, I couldn't find any complete or good resource for jwt auth in vue. Can you make one with production ready. 😀

  • @maneth3448
    @maneth3448 2 года назад +1

    100k congrats

  • @SirDamatoIII
    @SirDamatoIII 2 года назад +3

    Love Vue, would just like to have it render SEO friendly manner. Especially since SSR is not always an option. This I have seen done as an intercept, on routing where the SEO specific meta structure is sent when a the Google crawler bot is identified. Any ideas on something like this, as a bullet proof solution would be awesome since VueMeta is no longer applicable since the version Vue3 release.

    • @ProgramWithErik
      @ProgramWithErik  2 года назад +1

      Interesting. Well first, I really like SSG so there is Vue 3 plugins for SSG like github.com/antfu/vite-ssg. As for adding meta tags vue meta is in alpha for Vue 3. Also, I think Google crawlers work fine for SPA type apps now a days. I stilll prefer SSG for the speed though on blogs and contente heavy SEO sites.

    • @SirDamatoIII
      @SirDamatoIII 2 года назад

      @@ProgramWithErik Thanks for the kind reply, I will go and have a look as I am keen to find a way for static content generation (on public blog side of the app), while not touching anything behind the authenticated part of the app. My results with Vue even using Portals as per what VueMeta dev team was discussing with their upgrade for Vue3 support - was that the crawling is terrible when previewing Google bot’s scraping results. They do have a wait to load method for SPAs, but most other crawlers do not or are extremely lacking. So this is quite an interesting one as an SSR approach would best although as mentioned not always possible.

  • @web_chaos
    @web_chaos 2 года назад +1

    Sad😕
    1. I don't want make props drilling, but I did slot drilling
    2. Not reactive as expected, and needs yous additional code
    3. Most people need time to understand this pattern, also for experience programmers. In my opinion, this pattern almost never will be using in real projects

    • @ProgramWithErik
      @ProgramWithErik  2 года назад

      What pattern do you like?

    • @web_chaos
      @web_chaos 2 года назад +1

      @@ProgramWithErik Obvious and others develops can understand. Like in official documentation

  • @RaskaTheFurry
    @RaskaTheFurry 2 года назад

    I try to store all variables and methods in the root .vue file... unless they are component specific.
    like Table has sorting methods, im not gonna use that anywhere else.
    But getting data from API is at the top, because its provided everywhere and deep...

  • @pathtic7397
    @pathtic7397 2 года назад +1

    Primitive components = components which hasn'y any logic, like sections, text containers etc.?

    • @ProgramWithErik
      @ProgramWithErik  2 года назад +1

      I feel like they are the lowest level of components, like buttons, text inputs, forms. Things like those I consider primitives. They may or may not have logic

    • @pathtic7397
      @pathtic7397 2 года назад

      @@ProgramWithErik Ok, thanks :)

  • @IgorKravets81
    @IgorKravets81 Год назад

    I guess you could pass a component as a prop or in store and just use it in shadow box

  • @arjunvd2277
    @arjunvd2277 2 года назад

    Hi Erik,
    Can we use vue ( not vue client side ) inside already working .net core view page? is it possible? like vue packages?

    • @ProgramWithErik
      @ProgramWithErik  2 года назад

      There was a conference talk at last years Vue Conference where someone was using the 'reactive' Vue on the server side. You could look into that

  • @studiowebselect
    @studiowebselect 2 года назад +1

    9:18 onMonted is not the solution. Its because the child reasign the shadowText.

    • @ProgramWithErik
      @ProgramWithErik  2 года назад

      The onMounted gives a minute for the child to load before we change the text.... There was probably a few ways to handle it

    • @studiowebselect
      @studiowebselect 2 года назад

      @@ProgramWithErik yes.but it was mounted with the bad value first and was reprocess/paint after. In SSR you will have the bad text in SEO.

    • @studiowebselect
      @studiowebselect 2 года назад +1

      @@ProgramWithErik btw, you are one of my favorite youtuber!

  • @antfun8784
    @antfun8784 2 года назад

    buen video crack :b

  • @therealzaybee
    @therealzaybee 2 года назад +4

    It is very annoying to look at your folder structure in the right side

    • @PriyankBolia
      @PriyankBolia 2 года назад +5

      In one of the video, he showed why having folder structure on the right side is better for the eyes, when you hide that, the code stays at the same place.

    • @ProgramWithErik
      @ProgramWithErik  2 года назад +3

      Yeah, as @Priyank said, I put it on the right side because it's less movement when I close it of the code. I stole that from Jason at Netlify

  • @Kidziel
    @Kidziel 2 года назад

    Is it only me that cannot play the video?

  • @sergeichwelcome
    @sergeichwelcome 2 года назад +1

    First

  • @butbutmybutt
    @butbutmybutt 2 года назад

    hmm, v-html?