TL DR: The functional setState is generally useful to expect a correct state update when several setState are started in a short amount of time, when a regular setState performs a reconciliation and can lead to an unexpected state.
Please check out this great article on Functional setState for a clear understanding.
And here is the WORKING DEMO
First, you try to do different things in each of your cases, you assign pics in one and concatenate pics in the other.
Suppose this.state.pictures contain [1, 2, 3] , and pics contain [4, 5, 6]
this.setState({pictures: pics})
In the above case, this.state.pictures will contain photos ie this.state.pictures = [4, 5, 6]
this.setState(prevState => ({ pictures: prevState.pictures.concat(pics) }))
If in the above snippet this.state.pictures will contain previous photos + pics ie this.state.pictures = [1, 2, 3, 4, 5, 6]
In any case, you can customize it to suit your API needs, if it looks like a page-by-page response, you'd better concatenate the results for each request, otherwise if you get the whole array every time, just assign the whole array.
Normal setState VS Functional setState
Now your question is basically, perhaps you should use setState with an object or with a function.
People use both of them for various reasons, now the functional setState is considered safe, because React does something called a reconciliation process, where it merges several objects inside setState at startup often or simultaneously and changes are applied in one shot, sort of like a batch process . This can lead to unexpected results in scenarios like the ones below.
Example:
increaseScoreBy3 () { this.setState({score : this.state.score + 1}); this.setState({score : this.state.score + 1}); this.setState({score : this.state.score + 1}); }
As expected, the score will be increased by 3, but what React does will combine all the objects and update the score only once, increasing it by 1
This is one of the cases where a functional callback is lit because reconciliation is not performed on functions, and the execution of the code below will do something expected. ie update score by 3
increaseScoreBy3 () { this.setState(prevState => ({ score: prevState.score + 1 })); this.setState(prevState => ({ score: prevState.score + 1 })); this.setState(prevState => ({ score: prevState.score + 1 })); }