r/reactjs • • Mar 16 '23

Introducing react.dev: the new React docs site!

https://react.dev/blog/2023/03/16/introducing-react-dev
566 Upvotes

74 comments sorted by

View all comments

156

u/janaagaard Mar 16 '23

I found that the "You Might Not Need an Effect" page was a really helpful resource in understanding how React works.

https://react.dev/learn/you-might-not-need-an-effect

36

u/prawns_song Mar 17 '23

I’ve been trying to convince some peers to stop using unnecessary effects and I’m so glad there’s official documentation to point to now.

2

u/Ibelick Mar 17 '23

cool link to send when doing code reviewing

16

u/musical_bear Mar 17 '23

This is great. I’m going to be sharing this with my team tomorrow. I’ve been trying to explain some of this, but didn’t have great sources to back up what I was saying.

But I just learned some new things by reading this myself. I had no idea it was considered “ok” (in rare situations) to call a state setter right inside of a component function (as long as it’s nested in a condition). I would have used an effect for this case myself.

4

u/Aswole Mar 17 '23

Yeah, that part caught me as well. They did show a solution after which required neither, but had I seen the inline state setter in a code review, I would have flagged it.

9

u/Saifadin Mar 17 '23

I habe to admit, that I made some of these mistakes just out of laziness. This is definitely an amazing resource for anyone in any level of experience

5

u/janaagaard Mar 17 '23

So did I. We're still finding old, unnecessary useEffects in our code base. Most of the team has fortunately understood when it's possible to avoid them, so we're catching this is code reviews now, and slowly weeding the remaining ones out.

2

u/Negative-Manner-6978 Mar 17 '23

Great article, full of wisdom, nice find.

1

u/janaagaard Mar 17 '23

The new docs have actually been available for quite a while on beta.reactjs.org. Great to see that they have finally been released.

1

u/beeamie1 Mar 17 '23

I‘m rebuilding our funnel right now which used useEffect in every. single. component, multiple times. When I saw this page of the docs I was fully convinced to do it better. Really love the new docs.