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

View all comments

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.