Created
November 14, 2016 16:48
-
-
Save a-eid/3db3635ed5c28ec0aa269a08eefb85c4 to your computer and use it in GitHub Desktop.
difference btw comibineReducers with map and reduce ?
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
const combineReducers = (reducers)=>{ | |
return (state = {} , action)=>{ | |
Object.keys(reducers).reduce(function( nextState , key ){ | |
nextState[key] = reducers[key](state[key] , action); | |
return nextState; | |
} , {}) | |
} | |
} | |
const combineReducers = (reducers)=>{ | |
return (state , action){ | |
const nextState = {} | |
Object.keys(reducers).map((state , action)=>{ | |
nextState[key] = state[key](state[key] , action) | |
}) | |
return nextState | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment