Created
October 2, 2019 12:28
-
-
Save alonbardavid/795e794d0fc2ffbfa9bdc9a33614fac8 to your computer and use it in GitHub Desktop.
Patterns for deriving state gist7
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
function sortingReducer(state,action){ | |
switch (action.type){ | |
case actionTypes.SORT_BY: | |
const key = action.payload; | |
return { | |
list:state.list.sort((a,b)=>a[key]>b[key]?1:a[key]<b[key]?-1:0), | |
sortKey:key | |
} | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment