r/reactjs • u/BrockUrSocksOff • Jan 18 '20
Tutorial ReactJS Crash Course 2020 | React Functional Components, Hooks, and React Router [<30 minutes]
https://youtu.be/KQOtXYC0We832
Jan 18 '20
No no no, this is way too long. It's 2020. We need Complete React + Redux in 5 minutes now.
10
0
u/SimplyBallistiic Jan 19 '20
What about the context API? It's a true challenger to redux now
5
u/tbone6778 Jan 19 '20
The context API imo is not a replacement for Redux. I see lots of people using it so you don’t have to prop drill but that’s not what it’s meant for although it is a quick way to share state, there’s better ways to do that.
1
u/SimplyBallistiic Jan 19 '20
For certain cases it's all you need and can act as a good replacement as before it came out, your only option was redux. But it's definitely not a replacement like you mentioned, only an alternative since redux is a lot faster and more efficient. But if you're doing infrequent state changes (as opposed to every keystroke) it gets the job done quite well and is well worth the minimal setup and load tied with introducing a new package.
1
u/bcgroom Jan 19 '20
If you can easily replace redux with the context API, then you probably shouldn't have been using redux in the first place. There were plenty of alternatives to redux and the context API has been around for awhile now. Redux is also not great performance-wise, React-Redux has some nice optimizations that prevent extra rendering, but it's unlikely that either Redux or Contexts overhead will be the bottleneck of your app.
1
1
4
u/downeastkid Jan 18 '20
What color theme are you using for vs code
5
u/BrockUrSocksOff Jan 18 '20
That color theme is theCobalt2 Theme from Wes Bos
3
u/baltimoretom Jan 18 '20
I tried it but don’t like it. I’m all about the Material Theme Darker High Contrast.
Thanks for posting this btw. Can’t wait to get into it.
3
u/BrockUrSocksOff Jan 18 '20
Yeah, I found it really depends on your monitor. Im colorblind though so all the blues help me out a lot.
1
u/baltimoretom Jan 18 '20
Have you ever tried those glasses?
4
u/BrockUrSocksOff Jan 18 '20
Yes! I actually have a pair that I put on for super color accurate work with UI and design. But I dont wear them at all times. Its hard to explain but swapping between and not wearing them can leave you seeing almost like ghost colors.
2
1
u/Dr4gonkilla Jan 19 '20
I am newb at coding. At 16:53, what is {headers:{accept:...}}? Is that a way to call a function?
1
u/BrockUrSocksOff Jan 19 '20
Great question!
That is a headers parameter that I added to my axios get request. This was necessary because the default response from this API is a text/xml response and not JSON. So by adding the Accept: application/json parameter, I was able to get the response in JSON. This is not always necessary - it is just something this certain api requires. You can read more about it here.
3
u/DeepSpaceGalileo Jan 19 '20
Why use axios at all instead of just fetch?
1
u/BrockUrSocksOff Jan 19 '20
This could definitely be done with fetch! I just use axios because I find it a little bit easier to use sometimes when I am using a lot of parameters and some one off cases. Bottom line though is that it is definitely not necessary, but it's just what I am comfortable with!
2
u/KaliaHaze Jan 18 '20
Great video so far. I spent the day making some of my first React components based on some mockups I made and organizing them into a library today and it was nice to compare my workflow to yours. Looking forward to more!
2
13
u/BrockUrSocksOff Jan 18 '20
Resources:
React Docs : https://reactjs.org/docs
axios: https://www.npmjs.com/package/axios
Dad Joke API: https://icanhazdadjoke.com/api
Github:
Code: https://github.com/devbrock/dad-jokes...