Youtube in React: deleting previous search results to prevent flickering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {SEARCH_FOR_VIDEOS} from '../actions/search'; | |
import {REQUEST, SUCCESS} from '../actions'; | |
export default function (state = {}, action) { | |
switch (action.type) { | |
case SEARCH_FOR_VIDEOS[SUCCESS]: | |
return reduceSearchForVideos(action.response, action.searchQuery, state); | |
case SEARCH_FOR_VIDEOS[REQUEST]: | |
// delete the previous search element if we don't load more search results for the previous search query | |
return action.nextPageToken ? state : {}; | |
default: | |
return state; | |
} | |
} | |
/* ... */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment