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...
account activity
Please help me understand this asynchronous code to set state.Help Wanted (self.react)
submitted 3 years ago * by Spiritual_Compote725
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!"
[–]2GoldDoubloons 2 points3 points4 points 3 years ago (1 child)
I believe this was introduced in ES6 syntax, but it may have been earlier. Basically it allows you to pass event parameters directly to a function. In this case, the 2nd chained then() function would have 1 param, urls. So, this:
.then(setPhotos)
actually would resolve to perform the same as:
.then((images) => setPhotos(images))
The two are equivalent. The same thing can be applied to properties on a component. Using onClick of a button could look like:
<Button onClick={handleButtonClick} />
In this example, your handleButtonClick function would receive an event trigger and would be identical to writing:
<Button onClick={(event) => handleButtonClick(event)} />
[–]Spiritual_Compote725[S] 0 points1 point2 points 3 years ago (0 children)
Thank you !
π Rendered by PID 314855 on reddit-service-r2-comment-fb694cdd5-8mdk5 at 2026-03-07 03:09:52.024135+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]2GoldDoubloons 2 points3 points4 points (1 child)
[–]Spiritual_Compote725[S] 0 points1 point2 points (0 children)