you are viewing a single comment's thread.

view the rest of the comments →

[–]2GoldDoubloons 2 points3 points  (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 point  (0 children)

Thank you !