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

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.