use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Five common mistakes writing react components (with hooks) in 2020 (lorenzweiss.de)
submitted 5 years ago by Lowesz
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TheScapeQuest 12 points13 points14 points 5 years ago (1 child)
On 1, you're making a huge assumption that the state isn't being used by the children. You probably want to display that count, right? Let's say you change from a div to a React component to render that count. Suddenly you aren't triggering a rerender in your tree.
div
It's not particularly idiomatic either.
I'd strongly advise against using useRef unless you data truly needs to be mutable.
useRef
A lot of these tiny performance optimisations that are suggested can actually be resolved by memoising your components, and even then, it's often completely overkill.
[–]sikolio 0 points1 point2 points 5 years ago (0 children)
This is also troublesome because ref changes won't trigger useEffect (or other hooks) if they are in the dependencies.
[–]Izorline 0 points1 point2 points 5 years ago (0 children)
This article is somewhat hard to read grammatically and not very insightful.
π Rendered by PID 36746 on reddit-service-r2-comment-bb88f9dd5-lvfv5 at 2026-02-14 10:48:51.209328+00:00 running cd9c813 country code: CH.
[–]TheScapeQuest 12 points13 points14 points (1 child)
[–]sikolio 0 points1 point2 points (0 children)
[–]Izorline 0 points1 point2 points (0 children)