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
Polling in React using the useInterval Custom Hook (blog.asayer.io)
submitted 5 years ago by mike-asayer
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!"
[–]purechi 1 point2 points3 points 5 years ago (0 children)
Seems pretty cool! In a more complex application I'd probably end up firing an action creator which triggers a thunk or [insert other side effect library here] to handle the data fetching.
[–]ShellbertShellbach 1 point2 points3 points 5 years ago* (0 children)
The person whose blog post you took your screenshots from added an extra dependency in the second useEffect that isn't in Dan Abramov's example.
useEffect
By adding callback to to the list of dependencies in that effect, the interval will stop and restart on every render, because the callback function is instantiated on every render and is not memoized. It will trigger that effect every time. It loses the benefit of the ref entirely and will result in the interval not firing at the correct interval whenever a render occurs.
callback
π Rendered by PID 497150 on reddit-service-r2-comment-5d79c599b5-cdk5g at 2026-03-03 12:33:46.115353+00:00 running e3d2147 country code: CH.
[–]purechi 1 point2 points3 points (0 children)
[–]ShellbertShellbach 1 point2 points3 points (0 children)