I used to tell folks learning React to learn JS really well first. I had good intentions but was still gate-keeping πŸ˜”

But I do think knowing modern JS can really level-up your React skills and I've got top 10 features I think will help you be more awesome-r πŸ”₯πŸ”₯

[🧡 thread]
1. ES Modules

I see lots of confusion about when to use named vs default imports. The import style depends on how it was exported (named or default)

Named imports go within the curly braces & the single default import is outside of them πŸ€“ ImageImage
2. Arrow functions

Arrow functions can exist everywhere within your React app. Some folks (like myself) replace all functions with arrows while others only use them in spots

They really win w/ character savings but for those unfamiliar w/ the syntax they can lose w/ clarity 🧐 ImageImage
3. String interpolation

Pretty much anywhere where you used to use string concatenation, you can replace with string interpolation using string literals (the back-ticks) πŸ˜‰ Image
4. Enhanced object literals

JS object literals support a shorthand when the name of the key matches the existing variable name as well as computed property keys

I try to name my variables or my function arguments such that I can leverage object literal shorthand πŸ€— ImageImage
5. Array destructuring

Array destructuring makes it possible to easily pluck out ordered values in arrays and create variables. It's basically THE way to use the useState hook

I also really like using it with Object.entries combined with .map or .reduce πŸ™ŒπŸΎ ImageImage
6. Object destructuring

Object destructuring comes in super handy with plucking properties from component props, which can even be done w/ function arguments 😎 ImageImage
7. Spread operator

The goal with the spread operator (...) is to never mutate data, but make a copy first and add to the copy. JSX also supports the spread attributes.

The spread operator usually goes hand-in-hand with the rest operator (they look identical) πŸ‘€ ImageImage
8. Optional chaining

The optional chaining operator (?.) allows us to access properties deeply nested within an object without having to verify that each property level exists

When combined with the nullish coalescing operator (??) we can safely default a missing value 🀩 Image
9. Promises & Fetch API

Many asynchronous utilities, like `window.fetch`, now use promises instead of callbacks🀞🏾 Image
10. Async functions

Async functions enable asynchronous, promise-based behavior to be written in a synchronous style, avoiding the promise chains

And if you no longer have to support IE you should be able to use them native in the browser! 😍 Image
No need to use a thread unroll service to get these all on one page

I wrote a blog post listing all of these 10 modern JavaScript features that I believe will take your React skills to the next level πŸ€œπŸΎπŸ€›πŸΎ

Enjoy!

benmvp.com/blog/10-modern…

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Ben Ilegbodu πŸ€πŸ‘¨πŸΎβ€πŸ’»

Ben Ilegbodu πŸ€πŸ‘¨πŸΎβ€πŸ’» Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!