const updateSearchTopStoriesState = (hits, page) => (prevState) => {
const { searchKey, results } = prevState
Can anyone explain to me what does the above do? why is there 2 arrow functions?
This is the whole code
const updateSearchTopStoriesState = (hits, page) => (prevState) => {
const { searchKey, results } = prevState;
const oldHits = results && results[searchKey]
? results[searchKey].hits
: [];
const updatedHits = [
...oldHits,
...hits
];
return {
results: {
...results,
[searchKey]: { hits: updatedHits, page }
},
isLoading: false
};
};
class App extends Component {
...