Created
July 19, 2016 08:07
-
-
Save justin3737/b26c2008db09b0d40ed78651244cfcd0 to your computer and use it in GitHub Desktop.
Revisions
-
justin3737 created this gist
Jul 19, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ function reducer(state = [], action) { switch (action.type) { case 'ADD_ATTENDEE': // Return a new array with old state and added attendee. return [{ name: action.name, color: action.color }, ...state ]; case 'REMOVE_ATTENDEE': return [ // Grab state from begging to index of one to delete ...state.slice(0, action.index), // Grab state from the one after one we want to delete ...state.slice(action.index + 1) ]; default: return state; } };