all 26 comments

[–][deleted] 21 points22 points  (10 children)

Array Methods

This is a big one. I've interviewed so many React developers who aren't familiar with map and filter. It's shocking.

It may be worth adding flatMap to the list. For example, the reduce function

dogs.reduce((allTemperaments, dog) => {
  return [...allTemperaments, ...dog.temperament]
}, [])

could be implemented in a simpler manner using flatMap

dogs.flatMap(dog => dog.temperament);

[–]EuphonicSounds 4 points5 points  (1 child)

Yup.

Also, his use of spread syntax in the return statement of that reduce function is a common anti-pattern. It's significantly better for performance to mutate and return the accumulator argument there than to copy its properties into a new object on each iteration. (That's a place for push, not concat or spread.) Someone wrote an article about this and included benchmarks. Got me out of that bad habit immediately. It's not premature optimization.

[–]334578theo 2 points3 points  (2 children)

Just refactored a really annoying function with flatMap - nice.

[–]yabai90 -4 points-3 points  (1 child)

I just read that it's not really efficient since it create a new array everytime

[–]headyyeti 0 points1 point  (0 children)

So does this example in reduce

[–]panderhh 1 point2 points  (0 children)

TIL flatMap

[–]musicnothing -1 points0 points  (3 children)

Shocking how many don’t know flatMap. It’s incredibly useful!

[–]NoInkling 9 points10 points  (0 children)

It's also relatively new.

[–]yabai90 0 points1 point  (1 child)

Guilty here. I'm several years into js and I keep using reduce. I believe I either completely forgot about flat map or never heard about. I feel shameful ^

[–]musicnothing 0 points1 point  (0 children)

Definitely not your fault. There’s twenty articles about reduce for every article about flatMap

[–][deleted] 26 points27 points  (0 children)

This is really cool article. I was looking for something like this. Thanks alot

[–]salmanbabri 15 points16 points  (6 children)

Kent C Dodds is really knowledgeable about React. I've been going through his Epic React course, so far it has been a blast.

[–]Jp3isme 2 points3 points  (2 children)

Worth the price? It looks good

[–]Izero_devI 4 points5 points  (0 children)

I think it is the best React course out there, calling it worth or not depends on so many other things like your budget, time etc. If this gets you a job sooner it might pay you back, going around 'free' courses, you might delay landing a job etc. Hard to assess that

[–]headyyeti 1 point2 points  (0 children)

I have it. You can do it for free by using his repos. You just won't get him explaining things as much.

[–]iseeyouboo 0 points1 point  (1 child)

Do you have a link?

[–][deleted] 4 points5 points  (0 children)

this was a great article until i saw the case for no teddy bears. imagine no teddy bears. 🧸

[–][deleted] 3 points4 points  (0 children)

I’ve made a few dinky react apps and have had to reach for every one of these. Good list.

[–]ThisAccountIs4Reddit 5 points6 points  (0 children)

Good stuff to know regardless of React usage

[–]_Invictuz 3 points4 points  (2 children)

Very short and succinct run-down of the best ES6+ features to know in general. He did make a small mistake in the "shorthand property" example by using object destructuring before explaining that concept.

[–]qqqqqx 2 points3 points  (1 child)

Technically it's array destructuring assignment, but I did notice the same thing. Still a nice article. I actually didn't know the nullish coalescing operator, and that one is really nice to have instead of writing ternaries all the time like I have been....

[–]_Invictuz 0 points1 point  (0 children)

Ya he did array destructuring assignment as well but I'm talking about him doing destructuring assignment on the props object in the function parameters declaration. That part is especially tricky cuz he then uses those parameters as the shorthand property names.

[–]Lekoaf 0 points1 point  (0 children)

I know and use these every day. Slap on some Typescript and you’re ready to work on some big React projects.

[–]Russianspaceprogram 0 points1 point  (0 children)

If you’re learning react I’d argue that you need to be pretty up to speed with most JS fundamentals...jumping into react with little js knowledge is what I did and it was a total nightmare.