Skip to content

Instantly share code, notes, and snippets.

Last active November 25, 2018 12:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Youtube in React: deleting previous search results to prevent flickering
import {SEARCH_FOR_VIDEOS} from '../actions/search';
import {REQUEST, SUCCESS} from '../actions';
export default function (state = {}, action) {
switch (action.type) {
return reduceSearchForVideos(action.response, action.searchQuery, state);
// delete the previous search element if we don't load more search results for the previous search query
return action.nextPageToken ? state : {};
return state;
/* ... */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment