Created
November 3, 2018 13:45
-
-
Save productioncoder/2a5705ac3ab1237e306f6e84fe9d8e3f to your computer and use it in GitHub Desktop.
Youtube: watch details reducer: quick and dirty implementation
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
function reduceWatchDetails(responses, prevState) { | |
let byIdEntry = {}; | |
if (responses && responses[0].result.items) { | |
const video = responses[0].result.items[0]; | |
byIdEntry = {[video.id]: video}; | |
} | |
return { | |
...prevState, | |
byId: { | |
...prevState.byId, | |
...byIdEntry, | |
}, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment