Vuex Crash Course | State Management

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ต.ค. 2024
  • In this video we will build an application using Vue.js with the Vuex state management library.
    Check Out My Sponsor - Monday.com
    go.thoughtleade...
    Code:
    github.com/bra...
    💖 Become a Patron: Show support & get perks!
    / traversymedia
    Vue.js Crash Course:
    • Vue JS Crash Course (2...
    Website & Udemy Courses:
    traversymedia.com
    Follow Traversy Media:
    / traversymedia
    / traversymedia
    / traversymedia

ความคิดเห็น • 491

  • @TheCodeholic
    @TheCodeholic 5 ปีที่แล้ว +22

    It's not long time I discovered your channel and surprisingly all of the videos are REALLY valuable.
    ALL OF THEM...

    • @digitalturkistan1857
      @digitalturkistan1857 ปีที่แล้ว

      It's not long time I discovered your channel and surprisingly all of the videos are REALLY valuable.
      ALL OF THEM...

  • @Rahul-ym9uh
    @Rahul-ym9uh 4 ปีที่แล้ว +7

    You've got a special talent for keeping this simple and to the point. Even the pasting in of CSS is an excellent idea. Keep up the good work, you've got my money!

  • @izzatullokanoatov370
    @izzatullokanoatov370 5 ปีที่แล้ว +17

    I don't know , dude. Should I stand up or sit down for taking off my hat and say "THANK YOU, bro. That was mind blowing tutorial." . Good luck , bro.

  • @PaoPaw098
    @PaoPaw098 4 ปีที่แล้ว +17

    You can easily change the `$event` part in the filterTodos by this:
    Add/Replace this in FilterTodos.vue file
    1. __
    2. __
    _import { mapActions } from 'vuex';_
    _export default {_
    _name: "FilterTodos",_
    _data() {_
    _return {_
    _limit:0_
    _}_
    _},_
    _methods: {_
    _...mapActions(['filterTodos']),_
    _onChange() {_
    _this.filterTodos(this.limit);_
    _}_
    _},_
    _};_
    __
    Add/replace this in todos.js (module) file
    1. In _actions_ add this instead
    _async filterTodos({ commit }, limit) {_
    _const response = await axios.get(`__jsonplaceholder.typicode.com/posts?_limit=${limit}`)__;_
    _commit('filteredTodos', response.data);_
    _}_
    2. In _mutations_ add this instead
    _filteredTodos: (state, todos) => state.todos = todos_

  • @mixxamm
    @mixxamm 5 ปีที่แล้ว +270

    8:46 scaffold doesn't work anymore with the latest version of vetur, you should type 'vue' instead.

    • @LinkChenTW
      @LinkChenTW 5 ปีที่แล้ว +4

      Thanks for sharing this information. That's why I can't use "scaffold" now, and I even don't know this is not the default snippet.

    • @Spades340
      @Spades340 5 ปีที่แล้ว +1

      I got surprised this week with that too :(

    • @yonas8212
      @yonas8212 5 ปีที่แล้ว +2

      Thank you very much! I was wondering where did it go.

    • @synapps.filip.gorczynski
      @synapps.filip.gorczynski 5 ปีที่แล้ว +1

      Actually there are some templates provided by VS Code plugins, so when you enter vbase and hit tab it should expand into whole section, similarly vdata for data () { return { ket: value } and I suppose many more.

    • @LucXX36
      @LucXX36 4 ปีที่แล้ว +1

      This doesn't work for me anymore. Alternatively you can you "html", "js" and "css" to pass through Ventur the part of the component you need.

  • @DMANCHILD1
    @DMANCHILD1 5 ปีที่แล้ว +111

    Lets Go!! Brad don't stop ever!! Thank you sir.

  • @centrumsaiyan7623
    @centrumsaiyan7623 3 ปีที่แล้ว +2

    Thanks, i'm a working developer and this tutorial is industry standard. Learnt a lot.

  • @mrrolandlawrence
    @mrrolandlawrence 5 ปีที่แล้ว +4

    im a new convert to Vue. React was driving me nuts (jsx) and when i looked at Angular, Vue just looked better in every way. Thanks for these tutorials.

  • @LucXX36
    @LucXX36 4 ปีที่แล้ว

    At 47:15 you can just use something like "const limit = document.getElementById('id_name_of_select_element').value;" to get the value of the element. Don't forget to give your element the id you passed into this const variable

  • @oz5277
    @oz5277 2 ปีที่แล้ว +7

    for vue3
    index.js:
    import Vuex from 'vuex';
    import todos from './modules/todos';
    // Create store
    export default new Vuex.Store({
    modules: {
    todos,
    },
    });
    main.js:
    import { createApp } from 'vue';
    import App from './App.vue';
    import store from './store';
    const app = createApp(App);
    app.use(store);
    app.mount('#app');

    • @comunicloud30
      @comunicloud30 2 ปีที่แล้ว

      Thankyou Bro!!!!!!!!!!!!!!!!

    • @jehdiaizon
      @jehdiaizon 2 ปีที่แล้ว

      thank you! this worked when 18:59 wasn't working
      and the error I was getting was
      error 'axios' is defined but never used no-unused-vars

    • @riidom
      @riidom 2 ปีที่แล้ว +1

      uff I was going crazy on this thanks :D

  • @saurabh7199
    @saurabh7199 5 ปีที่แล้ว +50

    I recommended your channel to my friends who are interested in web development..

    • @TraversyMedia
      @TraversyMedia  5 ปีที่แล้ว +6

      Thank you :)

    • @saurabh7199
      @saurabh7199 5 ปีที่แล้ว +1

      @@TraversyMedia your welcome Brad. I hope you will continue to upload these great content videos in future.

    • @HimanshuPal-li7nj
      @HimanshuPal-li7nj 5 ปีที่แล้ว +4

      & I recommend it to anyone who is not even interested in web Technology .....

  • @KehindeOrilogbon
    @KehindeOrilogbon 5 ปีที่แล้ว +31

    Brad is a mind reader... Just opened vuex docs yesterday and still on it, then he uploads this video :D. Thanks Brad

  • @allandacasin9041
    @allandacasin9041 4 ปีที่แล้ว +71

    Life should be simple or minimal. I'm moving now to Vue from React.

    • @maskman4821
      @maskman4821 4 ปีที่แล้ว

      awesome !!!

    • @xenon-x54
      @xenon-x54 4 ปีที่แล้ว +2

      yeah IMO React is trash

    • @i-am-learning-life
      @i-am-learning-life 4 ปีที่แล้ว

      Same here 🤣🤣

    • @romankocherezhchenko34
      @romankocherezhchenko34 3 ปีที่แล้ว +3

      I have no idea why people still use React, when Vue, Svelte and other awesome framworks exist, idk

    • @romankocherezhchenko34
      @romankocherezhchenko34 3 ปีที่แล้ว +3

      @@asanokatana Even junior can rebuild React app to Vue, but Vue to React don't.

  • @cll1out
    @cll1out 5 ปีที่แล้ว

    i just got done watching your vue.js crash course you updated back in January. You said you were gonna do this video "in a couple months." This posted in March. Love how spot-on you were with actually delivering on that promise. Good work sir!

  • @moonkey45
    @moonkey45 4 ปีที่แล้ว +2

    If you want to use mapGetters like he does in 17:26 you now have to add the spread operator pointpointpoint infront of it -> *...mapGetters(['allTodos'])*

  • @storyden5
    @storyden5 5 ปีที่แล้ว +1

    Sir I love your Videos, but Have it in mind that the next generations won't forget a Hero like you..

  • @jasonjjavier6693
    @jasonjjavier6693 5 ปีที่แล้ว +7

    Your Crash Course is great, I have watched it since I'm in first year college and now I'm in an industry. Great help! Thank you.

    • @christianm6268
      @christianm6268 4 ปีที่แล้ว

      wow thats a very nice of u jason. good to know

  • @SamatTolkunbekov
    @SamatTolkunbekov ปีที่แล้ว

    Man this is gold, keep recording new lessons. Explanation, visual are on point, and most importantly it is brief.
    Subscribed and added to watch list on the second video.

  • @harbilito4910
    @harbilito4910 5 ปีที่แล้ว +12

    47:30 , you could just type $event.target.value in the @change method in FilterTodos.vue

    • @kyrierevival3658
      @kyrierevival3658 5 ปีที่แล้ว

      also use event target value in todos.js?

    • @benjaminwaye6477
      @benjaminwaye6477 4 ปีที่แล้ว +2

      ​@@kyrierevival3658 I boiled it down to const limit = parseInt(e.target.value); but I notice there are more concise options

    • @adityakunhare
      @adityakunhare 4 ปีที่แล้ว +3

      None of it is working, I am getting event.target is undefined in the todos.js (module) on console.log

  • @jonathanvanhoof9976
    @jonathanvanhoof9976 5 ปีที่แล้ว +1

    Thanks Brad. I'm learning Vue and this is really helpful. Also what I like is you don't speak / code too fast so that I can code while you speak.

  • @petarstoyanov8976
    @petarstoyanov8976 5 ปีที่แล้ว +5

    Thanks, Brad!
    That really helped me understand faster how to use Vuex. It's simple and elegant. So easy once you get the hang of it. Keep up to awesome work!

  • @PhonePhaan
    @PhonePhaan 3 ปีที่แล้ว

    really good tutorial, I was just brushing my vuex skills,
    Quick note: - instead of using event for filter you can use local data(state) and on change on select makes it easier

  • @rakibulhasan8431
    @rakibulhasan8431 4 ปีที่แล้ว

    your tutorials help me a lot for my first job as a software engineer. I'm grateful to Traversy media

  • @cyphen21
    @cyphen21 5 ปีที่แล้ว

    Subscribed to this channel like 8 months ago. Dont regret it at all.

  • @microman99
    @microman99 2 ปีที่แล้ว +1

    For those who encountered TypeError: Cannot read properties of undefined (reading 'use') -- Remove the line Vue.use(Vuex) in index.js will do. It took me hours to figure it out :")

  • @PB72UK
    @PB72UK 5 ปีที่แล้ว +5

    Great timing , just learning vuex myself :) so this should be very helpful, will we be seeing a nuxt crash course soon? Hope so!

  • @cajogos
    @cajogos 4 ปีที่แล้ว +3

    Can always count on you to have a tutorial for things I need to quickly learn.
    I hope you don't mind I listen to your videos on 1.75x speed! You still sound awesome! I just lack time these days... It's not you... it's me.

  • @mr.webdev3700
    @mr.webdev3700 5 ปีที่แล้ว +30

    Thank you for providing so much value to the community!!! 👍👍👍👍👍👍👍👍👍👍👍👍👍👍

  • @timbass9822
    @timbass9822 5 ปีที่แล้ว +1

    This was a good course Brad, but I think you made a mistake to show only using ...mapActions and ... mapGetters when writing Vuex code, as it is easier (and cleaner in many cases) to use this.$store.dispatch() and this.$store.commit() in components versus overly complicating things trying to be elegant using the ...map feature of Vuex when you can just use the global. Thanks for the good work!

  • @andrewkiminhwan
    @andrewkiminhwan 5 ปีที่แล้ว

    no one else is uploading consistently like brad on youtube. the absolute GOAT

  • @colinmignot6309
    @colinmignot6309 5 ปีที่แล้ว +2

    Thank you for being soooo generous. I have 2 days of programming experience haha and your channel is really inspiring me to work learn work learn work learn.

  • @Indialoves1
    @Indialoves1 4 ปีที่แล้ว

    Brad, I am not only learning new things from you but also the coding structure you do is very clear and easy to understand.

  • @steps0x029a
    @steps0x029a 4 ปีที่แล้ว +1

    Thank you so much! After watching the Vue Crash Course and this one, I immediately became a patron. Love your content!

  • @railroadandindustrialsky-wv8ns
    @railroadandindustrialsky-wv8ns ปีที่แล้ว

    Clear and concise walkthrough. You got me a job Brad. Thanks.

  • @TheBaltLT
    @TheBaltLT 3 ปีที่แล้ว

    Much appreciated. Thank you for the quality and no annoying selfies. Best of luck.

  • @benpohl7186
    @benpohl7186 5 ปีที่แล้ว

    Our team is switching to Vue and this tutorial has been super helpful for me. Thank you so much!

  • @ebrahimmohammadi5489
    @ebrahimmohammadi5489 4 ปีที่แล้ว

    It is one of the shortest and best videos to learn using Vuex in your projects, Thanks Brad and thanks Traversy Media

  • @spongechameleon6940
    @spongechameleon6940 4 ปีที่แล้ว

    Wow man, your stuff has always been great but this video in particular is really a whole new level. I learned way more from this than I thought I was going to. Thank you man, hope you're healthy and vibing in quarantine

  • @johnnya1717
    @johnnya1717 3 ปีที่แล้ว

    you're the only one who describes things clear. thank you

  • @sweetberries4611
    @sweetberries4611 5 ปีที่แล้ว +1

    Literally stumbled upon this problem in my project, glad to find vuex

  • @interpulse
    @interpulse 5 ปีที่แล้ว +1

    You are the best teacher I've come across... Thanks for keeping it real. Respect

  • @pixikraft9617
    @pixikraft9617 5 ปีที่แล้ว

    Thank you Brad. We are so so lucky to have you and i wish you success in all your projects because you deserve it.

  • @melrok1
    @melrok1 3 ปีที่แล้ว

    this channel is guaranteed to be a subscription. Keep going and I wish you a lot of success.

  • @overnightmares
    @overnightmares 5 ปีที่แล้ว +16

    Hi Brad,
    @48:00 why didn't you just use e.target.value ?

  • @nvjrane
    @nvjrane 4 ปีที่แล้ว

    This is the best video ever for learning VUEX in such a short time. Thanks a lot! Keep going!

  • @damionatcodememory137
    @damionatcodememory137 5 ปีที่แล้ว +2

    Brad this tutorial was so clear and informative! Keep up the excellent work!

  • @SebastianPerezG
    @SebastianPerezG 5 ปีที่แล้ว

    I'm just starting with vuex , this tutorial comes very handy !!! , i like the way that you explain man.

  • @gaos94
    @gaos94 5 ปีที่แล้ว

    Thanks Brad! I got interested in web development thanks to you, I currently have 2 years working mostly on React, don't love Vue (don't dislike it either) but is good to know other ways to do the same thing.

  • @MuhammadRizkyEkaArlin
    @MuhammadRizkyEkaArlin 5 ปีที่แล้ว

    These crash courses are absolute miracles!!! Enough to get you started without leaving a confusion :D

  • @petersutton1609
    @petersutton1609 4 ปีที่แล้ว

    Thanks Brad, was pulling hair after moving project to SPA with vue-router, this is the way to go!! :)

  • @HostDotPromo
    @HostDotPromo 5 ปีที่แล้ว +1

    Thanks, this helped clarify a few things for me. State management can be confusingly awesome.

  • @mehtabahmed6092
    @mehtabahmed6092 2 ปีที่แล้ว

    Thank you so much, you really made my life essay as I needed it in my thesis. Most important the comparsion with Redux was very useful as I knew it already.

  • @steliosvoskos9610
    @steliosvoskos9610 4 ปีที่แล้ว

    Thanks for sharing such high quality material for free. Excellent course about Vue and Vuex - I am starting a new role on Monday and those courses helped a lot.

  • @speaktothepoint2108
    @speaktothepoint2108 5 ปีที่แล้ว

    Edison didn’t sleep 8 hours per day because, he didn’t ask internet for an advice. Hard work has no substitute. Thanks Brad.

  • @kshirodpatel
    @kshirodpatel 5 ปีที่แล้ว

    Brad love you man. The way you describe those stuffs it looks like wow how easy was that.

  • @chenqu773
    @chenqu773 3 ปีที่แล้ว +1

    Nice tutorial! I am using vue/cli 4.5.13 and there are some incompatibility issues. For new version of vue/cli, it's better to select vuex directly from the vue project creation wizard, which will setup the vuex environment correctly for you.

  • @RawCoding
    @RawCoding 5 ปีที่แล้ว

    Great to see sucha massive tutorial dedicated solely to vuex. Well done

  • @acollierr17
    @acollierr17 5 ปีที่แล้ว

    Thank you so much for this video and in general what you do! For a while, I have been quite confused about state management. But my confidence has increased after watching this video. Time to implement and build a foundation from this video for my own site. Again, thank you!

  • @PatrickSierak
    @PatrickSierak 4 ปีที่แล้ว

    In between the grid spaces of todos it is actually an optical illusion. You see grey dots between the spaces of the todos you are not looking at 35:36

  • @dulerong5
    @dulerong5 4 ปีที่แล้ว

    Thank you so much Brad, your content is one of the most educational content on TH-cam, thank you.

  • @divyavishwakarma2002
    @divyavishwakarma2002 3 ปีที่แล้ว

    You could've also filtered the todos by emitting an event from the child component and passing range from there to the parent component. I did it this way and it doesn't even require you to make a new request to the server.

  • @kamalhm-dev
    @kamalhm-dev 5 ปีที่แล้ว +23

    nuxt js next please!

  • @gillfromamritsar
    @gillfromamritsar 5 ปีที่แล้ว

    you are doing an awesome work!, I have recommended your channel to lot of friends to learn and move forward in career.

  • @nerrdii
    @nerrdii 5 ปีที่แล้ว +1

    Some suggestions...
    1. You can use e.target.value when filtering
    2. When updating, you can use a patch request and just pass in completed in the request body, and call the update todo action directly in the double click listener
    Great video as always!

  • @collinsikotun1436
    @collinsikotun1436 9 หลายเดือนก่อน

    Just really need to thank you cos you make things seem super easy, Kudos

  • @mk-13579
    @mk-13579 5 ปีที่แล้ว +1

    Awesome content, Brad. Thanks a lot.
    These crash courses you make are just gold. Its so awesome to get up to speed on few things here and there so quickly.

  • @virginielaborde9440
    @virginielaborde9440 3 ปีที่แล้ว

    great course! quick, detailled & helpful, even if you never worked with state management

  • @IngPedroAraujo
    @IngPedroAraujo 5 ปีที่แล้ว

    This was a great video tutorial; It helps me clarify some concepts about Vuex. Obviously, this is not for a beginner. Great job! Thank you for sharing your knowledge; I wish you success in everything you do. Thank you

  • @AvenalSzarosiwy
    @AvenalSzarosiwy 5 ปีที่แล้ว

    Hoooly... i just watched vue crash course and i thought it would be cool if you could do vuex course. You are a beast, Brad!

  • @andrewschimelpfening781
    @andrewschimelpfening781 4 ปีที่แล้ว

    I think this is a really good intro to Vuex. Do you have an example that uses multiple modules, or an authentication flow with Vuex?

  • @AdnanAbbasi_LXXVIII
    @AdnanAbbasi_LXXVIII 3 ปีที่แล้ว

    Excellent video again, I so much like following your videos, explained in very detail and thorough, I like the fact that you make a mistake and then fix it in front of us, everything is so natural :-)

  • @nuradiltursun6298
    @nuradiltursun6298 4 ปีที่แล้ว

    jsut complete right now,step by step......thank you man

  • @diegoardila7384
    @diegoardila7384 3 ปีที่แล้ว

    Great Class man!! congratulations, but only one question... why don't you use mapState in order to get the State from the store, is there any performance reason that I didn't take into account??

  • @yeorinim2sida
    @yeorinim2sida 4 ปีที่แล้ว +7

    8:46 "scafold(tab)" changed to "vue(tab)"

  • @lerouxvermeulen4403
    @lerouxvermeulen4403 2 ปีที่แล้ว

    Damn dude, what a lifesaver! You are the best.

  • @benjaminwaye6477
    @benjaminwaye6477 4 ปีที่แล้ว

    Excellent tutorial! I noticed that removing some await(s) fixed the timing issue

  • @EdwardGranville
    @EdwardGranville 4 ปีที่แล้ว

    Sir, you seriously rock! Very well explained in a relaxed and clear way.

  • @gilangamri
    @gilangamri 3 ปีที่แล้ว

    great intro to Vuex, thank you very much. I'm new to vue and vuex, but I have a question after I saw you create an action for filter, does it have to fetch another API request to filter the todos? won't it be possible to just filter from the todos state w/o having to call another API request?

  • @BenHayat
    @BenHayat 5 ปีที่แล้ว

    Hi Brad;
    I'd like to make a suggestions:
    Since Udemy doesn't have a feature for student to follow an instructor (Like pluralsight has), where when an instructor publishes a new course all the followers get email of the new course. Unless I've missed it, I can't find it on Udemy.
    My suggestion is, when you have a NEW course on Udemy, create an intro video here (2 minutes) to describe the course and you get TH-cam to notify 675,000 subscribers for you. This way if I see the course that fits me, I go an buy it. In the intro you can offer discount if you want.
    In fact you should tell Udemy to offer feature that students can follow instructor.
    ..Ben

  • @raistlinmajere2257
    @raistlinmajere2257 5 ปีที่แล้ว +5

    Are you going to do a Vue.js Udemy course? If you do sign me up.

  • @nilmendes7710
    @nilmendes7710 4 ปีที่แล้ว

    This tutorial helped me a lot!
    Valuable tips.
    Thanks for sharing your knowledge and time.
    Success in your projects.

  • @adrianoalves-qripto
    @adrianoalves-qripto 5 ปีที่แล้ว

    Thank you very much Brad for your passion and knowledge sharing. Greetings from Brazil Vuejs Community!

  • @tepchiva8342
    @tepchiva8342 3 ปีที่แล้ว

    I recommended your channel to my friends who are interested in web development,
    I'm so thank you for good video share 💖💖💖

  • @kiambojyms2196
    @kiambojyms2196 2 ปีที่แล้ว

    Thanks. It has really helped me. I really like your videos.

  • @DarknessDescend
    @DarknessDescend 4 ปีที่แล้ว +1

    Just like aways, I've learned a lot here! Thank you, dude!

  • @arnoldgamarra8425
    @arnoldgamarra8425 4 ปีที่แล้ว

    Hi from Peru, thanks for sharing this awesome course about VUEJS

  • @EricLansher786
    @EricLansher786 4 ปีที่แล้ว

    Your content is amazing, Simple and very effective. Keep it up.

  • @joseraimundofernandesfilho7570
    @joseraimundofernandesfilho7570 5 ปีที่แล้ว +1

    Hello Brad. I really enjoyed your videos. May I ask if you ll do a Nuxt Crash Course?

  • @alecprologg
    @alecprologg 3 ปีที่แล้ว

    So clear and concise, as always ! Thanks a lot Brad !

  • @korndev6862
    @korndev6862 5 ปีที่แล้ว

    this crash course is very nice, i so understand everything about vuex. thank you very much sir.

  • @dandyooo
    @dandyooo 4 ปีที่แล้ว

    Thanks for using REST API. Other tutorials are like using manual hardcoded datas which are not actually the best idea for this kind of tutorial.

  • @CODINGISEASY
    @CODINGISEASY 5 ปีที่แล้ว +2

    Another fantastic tutorial! Thanks brad!

  • @misterhtmlcss
    @misterhtmlcss 5 ปีที่แล้ว

    I've seen recently some debate on Reddit regarding where to put the JWT whether it should be in state, localstorage or a cookie. Where do you come down on this Brad? I ask because @ 3:50 on your Vuex Terms slide the State term includes 'token' as one of your examples. I'd love to hear your thoughts on how to handle Auth within the Vuejs/Vuex app

  • @matejl92
    @matejl92 5 ปีที่แล้ว

    Thanks for the video, it was helpful! However I noticed that you did not use async/await when calling the store actions which you should.

  • @fernandobravodiaz3972
    @fernandobravodiaz3972 3 ปีที่แล้ว

    A nice tutorial. Simple, concise and well explained.

  • @michaelbarilla
    @michaelbarilla 3 ปีที่แล้ว

    If your having trouble with the $event part when filtering todos because your not using commit and can't compile the app you can by pass it by just placing commit(); at the end. you'll get a console error because its an empty commit, but at least you'll be able to compile and see the event in the logs. if you take out the commit part to try to compile and just pass in e, it will end up using e as the 'commit' and you wont see the event

    • @lubomirhorvath823
      @lubomirhorvath823 3 ปีที่แล้ว +1

      Just tell eslint to ignor the line for a while.
      // eslint-disable-next-line
      async fetchTodos({ commit })
      Later you should remove the ignore line code.

  • @can9113
    @can9113 5 ปีที่แล้ว

    Amazing. Thanks to you I understood all the topics about Vuex.

  • @michaelkendagor4322
    @michaelkendagor4322 3 ปีที่แล้ว

    This has been life changing to me .. thanks man.. God bless

  • @Cpt_Chirp
    @Cpt_Chirp 5 ปีที่แล้ว

    fantastic tutorial. perfect speed and everything is super clear.

  • @anilchudasama7698
    @anilchudasama7698 2 ปีที่แล้ว +1

    Big help bro..best content...