Created
November 5, 2016 07:27
-
-
Save smhatre59/1fb71003a952bca0c2f68714304716f9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export default function reducer(state={ | |
users:[], | |
fetching: false, | |
fetched: false, | |
error: null | |
}, action){ | |
switch (action.type) { | |
case "FETCH_USERS":{ | |
return {...state, fetching: true} | |
} | |
case "FETCH_USERS_FULFILLED":{ | |
return { | |
...state, | |
fetching: false, | |
fetched: true, | |
users:action.payload | |
} | |
} | |
case "FETCH_USERS_REJECTED":{ | |
return { | |
...state, | |
fetching: false, | |
error: action.payload | |
} | |
} | |
} | |
return state; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment