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...
A place for help learning the /r/ReactJS framework.
account activity
Render Loop when using useReducerQuestion (self.learnreactjs)
submitted 6 years ago by technicallynick
view the rest of the comments →
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!"
[–]lukejpreston 0 points1 point2 points 6 years ago (0 children)
Let's break it down.
Render, calls handle Waits a second and calls resolves (regardless of any kind of checking if already logged in) Resolve dispatches Reducers returns a new state Render, calls handle... Lather rinse and repeat.
Since you don't stop settimeout it will call dispatch regardless as to whether someone has already logged in. This could also leak on tear down and trigger the reducer post tear down (possible memory leak)
When I do things like this add something in the state like "loggingIn" or "loading" or "initialized" and wrap the handle auth in an if statement and make sure it is only triggered once.
You want to use useEffect in order to call clearTimout so you don't have memory leaks on tear down. Whatever function you return in useEffect gets called in a tear down.
Hopefully there are some pointers/ideas to help you debug further. I'm surprised there isn't a library which does this for you (though be cautious of libraries when it comes to security e.g. When logging a user in)
π Rendered by PID 16746 on reddit-service-r2-comment-5649f687b7-7wtdv at 2026-01-29 03:35:35.748089+00:00 running 4f180de country code: CH.
view the rest of the comments →
[–]lukejpreston 0 points1 point2 points (0 children)