Many of my students tried to learn a framework (often React or Angular) first, got stuck, and decided to dig into vanilla JS first.
Many of them also try to learn a framework again after going through my guides or Academy training program and often tell me that it’s a lot easier once you understand how the language actually works.
The other day, a reader asked me:
What core vanilla JS concepts should you learn if you eventually want to learn React?
As someone who doesn’t personally enjoy or use frameworks, I decided to ask my students who had made that transition what they found most helpful. Here’s what they told me.
That’s a really interesting question!
I’m definitely not as expert in React as other folks, but I would say, in no particular order:
- ES6 - it’s not strictly required, but basically everyone uses it, so every tutorial and blog post and help doc will be written with it.
map()— gonna use tons of mapping, like over lists of data to render components or to modify the data client side
- destructuring - this was super mysterious to me before React but I don’t work in a single file without it now.
- spread props - similar to destructuring, it’s really handy when passing around and sharing props (object basically) all over the place
- implicit vs. explicit return - you’re constantly switching between the two, since React is very picky about when and you return inside components.
- ternaries and short-circuit logic — two techniques used a lot in React, too, to help with the all conditional rendering
- array and object methods —
keys(), etc. props are tons of arrays and objects
- truthiness — for example, knowing the difference between
undefinedand quirks like 0 being falsy
- deep vs shallow copying — Chris and I just went over this recently, and it consistently trips me up when I stop working in react for a bit. you need to do lots of copying data to mess with it, so need to know how to safely do that.
Those are the first things that come to mind.
For sure, you can basically forget all the DOM things you learned! You never really interact directly with it in React, or at least not in the same way.
I would recommend to try to learn “raw” React first.
I didn’t and I wish I did.
I highly recommend Wes Bos’s React for Beginners - took it a couple years back and it was awesome.
It may be a lot to take in, but essential stuff . Oh, and he updates his videos to latest and greatest all the time.