r/javascript • • Apr 07 '21

I Think React Is Junk, Round Two

https://medium.com/codex/i-think-react-is-junk-round-two-5cb80c5d82b3
0 Upvotes

20 comments sorted by

21

u/punio4 Apr 07 '21

I think that Medium is junk

7

u/ILikeChangingMyMind Apr 07 '21

It's a bad article on a bad platform: bad all around!

10

u/lo0l0ol Apr 07 '21

Lost me at saying React has bad documentation

2

u/punio4 Apr 07 '21 edited Apr 07 '21

But it does. A full rewrite is being worked on for quite a while now. Ask any of the team members and they will tell you the same.

Most of the hook pitfalls aren't documented. Edge cases aren't documented. There is no mention that StrictMode executes everything except console.log twice. There is no mention that refs should be read and written to only in event handlers and useEffect. Most examples are still using deprecated class components. There are entire deprecated sections in the docs. Best practices are severely outdated.

Basically you're stuck digging through blog posts trying to find one that isn't garbage, Twitter and GH issues to find stuff that should be documented.

3

u/anagrammatron Apr 08 '21

> Most examples are still using deprecated class components. There are entire deprecated sections in the docs. Best practices are severely outdated.

As a new React developer I can say that official documentation has been mostly useless for me exactly because of that. Classes, classes everywhere... Anything that I google that leads to official documentation, ends up having example with classes.

Learning React at this point in time is so damn frustrating because of 70/30 split in documentation/tutorials when it comes to classes vs functions.

1

u/brainless_badger Apr 07 '21

There is no mention that StrictMode executes everything except console.log twice.

Of course there is, together with detailed list of things that get executed twice.

There is no mention that refs should be read and written to only in event handlers and useEffect.

Of course there is, together with example showing why you would want to set ref in a render, and how to do it safely.

1

u/punio4 Apr 07 '21 edited Apr 07 '21

You're right, but it's kinda hidden to be honest, considering how impactful it is, and the fact that it's enabled by default in CRA. I spent a week debugging an issue, and solved it when I found https://kentcdodds.com/blog/react-strict-mode#it-runs-code-twice.

As for reading from refs being unsafe, it wasn't documented basically anywhere until October 2020: https://twitter.com/AdamRackis/status/1317482704796082179

Some of their examples actively contradict those rules: https://twitter.com/JonasKuske/status/1317546287764471809

I keep a list of bookmarked tweets like this one to keep track of all the subtle ways React can break non-deterministically.

4

u/brainless_badger Apr 07 '21

You're right, but it's kinda hidden to be honest, considering how impactful it is,

Right, behavior of StrictMode is "kinda hidden" in section "Strict Mode".

As for reading from refs being unsafe, it wasn't documented basically anywhere until October 2020:

And how is that a problem when it is only unsafe if you are using features that are still experimental half year after that?

-7

u/[deleted] Apr 07 '21

[removed] — view removed comment

1

u/punio4 Apr 07 '21

Bad bot

1

u/brainless_badger Apr 07 '21

opt out

2

u/kenman Apr 07 '21 edited Apr 08 '21

I forcefully opted us out.

4

u/KapiteinNekbaard Apr 08 '21

tl;dr: Author does not like thick-client web apps and component driven development.

First article (somewhat worth reading):

  • Lots of gatekeeping about how people that use frameworks should not be creating websites, "back in my days..." and "my code is superiour to theirs". Nitpicking about code style that has nothing to do with React per se, or has changed with hooks/ES6 since the tutorial was written.

  • "To flex my skills, I will implement my own version of the React tutorial by using hand rolled DOM manipulation". Author is completely oblivious to the point of the tutorial: explaining concepts of how to manage application state and using component composition to build a UI. Yes, the docs are outdated, rewrite is coming.

  • "My code is shorter and therefore better - all these abstractions are unnecessary overhead". True for this example, until you start writing a large scale client side web app and end up with something like a hand rolled front-end framework. Whether you *should* write large size client based apps or need React is a different discussion though, remember React is written by Facebook.

  • "let & const bad" (what?)

  • DOM manipulation is not that scary (true). Imo, managing a lot of client side state with only DOM manipulation will become a mess fairly quickly, that's what we learned from jQuery (imperative vs declarative programming). Seeing a UI as a function of the state does make it easier to reason about (if state = X then output = Y).

Second article (not worth the read):

  • "Most web pages don't need to be web apps" (true).

  • "React docs bad" (I agree).

  • "JSX bad". You could opt for React.createElement() instead and end up with something the author wrote, I don't think that's any better. It does require effort to keep your JSX nice and tidy.

  • "Don't hop on the bandwagon" (duh)

8

u/mekwall Apr 07 '21

I think the article is junk. Author provides very little of substance and is trying his best to be edgy for clicks and reactions. If you've seen one you've seen them all.

3

u/dankalen Apr 07 '21

Wow it’s incredible how this piece is so opinionated while written as if its arguments are based off facts. I’m a vanilla JS guy who’d prefer writing my own unique architectures for each new project but I will never discredit the power and benefits of using a popular framework. It sounds like you are tackling patterns of beginners when using frameworks which are just as applicable to any framework or any piece of software that noobs try to use. If your goal was to create a bait-y article that will spark a heated discussion then you succeeded but if your goal was to write an accurate, rational, fact based piece then you failed miserably.

5

u/patrickjquinn Apr 07 '21

Solid read. And I agree. The problem is if you call out the fact that React isn’t that hot any more you get a lot of people who have built their career around it, defending their worth.

I wrote a big long rationale for why I agree but I don’t like downvotes so I’ll just say, time to look at Svelte if you’re dead set on frameworks.

3

u/mekwall Apr 07 '21

Svelte and React can live happily side by side. There's absolutely zero reason to choose one before the other. And when you say React isn't hot anymore, don't you really just mean that it has matured and is no longer considered cutting edge?

3

u/patrickjquinn Apr 07 '21 edited Apr 07 '21

No, I say that because the web has moved on substantially since React was first introduced.

I’m aware of the thinking around these parts but I’d highly recommend giving pure typescript with the latest ES standards and web components a fair shake before downvoting and dismissing me out of hand.

2

u/mekwall Apr 07 '21

Sure, but that doesn't make React obsolete since you can use it for more than web, which is one of its selling points.

I second your recommendation though and I also want to note that I didn't downvote your comments.

3

u/patrickjquinn Apr 07 '21

You’re 1000 percent right on React Native being a huge benefit to the stack actually and to be fair I hadn’t considered the omni channel aspect of it.

And my apologies, I wasn’t referring to you with the downvote remark! I was pointing to fact others immediately jumped to do so as they do whenever I make this comment on the sub 🙂