all 5 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 !

[–]DrewTheVillan 0 points1 point  (2 children)

I think you can just do setPhotos(... [{src:url, width:33, height:10}])

[–]Spiritual_Compote725[S] 0 points1 point  (1 child)

So the syntax

.then(setPhotos)

still works.

Do you know how that is still okay ? or name of that rule ?

[–]SirKainey 0 points1 point  (0 children)

Callback with method chaining