Skip to content

Instantly share code, notes, and snippets.

Last active Nov 24, 2018
What would you like to do?
Youtube in React: search for videos reducer
function reduceSearchForVideos(response, searchQuery, prevState) {
let searchResults = => ({...item, id:}));
if (prevState.query === searchQuery) {
const prevResults = prevState.results || [];
searchResults = prevResults.concat(searchResults);
return {
totalResults: response.pageInfo.totalResults,
nextPageToken: response.nextPageToken,
query: searchQuery,
results: searchResults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment