-
-
Save indigoviolet/dd4cbab7c39c293ed83d17bad8334f85 to your computer and use it in GitHub Desktop.
fin blog embed
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 postsReducer( | |
state = { | |
isFetching: false, | |
data: [], | |
error: null, | |
}, | |
action | |
) { | |
if (action.type === FETCH_POSTS) { | |
switch (action.readyState) { | |
case REQUEST: | |
return Object.assign({}, state, { | |
isFetching: true, | |
}) | |
case SUCCESS: | |
return Object.assign({}, state, { | |
isFetching: false, | |
items: action.data.posts, | |
}) | |
case FAILURE: | |
return Object.assign({}, state, { | |
isFetching: false, | |
error: action.error | |
}) | |
default: | |
return state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment