Last active
August 5, 2017 11:21
-
-
Save maxired/52997a622aa912e8b6c5071697882327 to your computer and use it in GitHub Desktop.
immutable reducer
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
switch (action.type) { | |
case ADD_NEW_AVAILABLE_COLOR_TO_CAR:{ | |
const { color, model, manufacturer } = action.payload | |
return {...state, manufacturer: { | |
...state.manufacturer, [manufacturer]: | |
{...state.manufacturers[manufacturers], models: | |
{...state.manufacturers[manufacturers].models, [model]: | |
{...state.manufacturers[manufacturers].models[model], options: | |
{...state.manufacturers[manufacturers].models[model].options, colors: | |
{...state.manufacturers[manufacturers].models[model].options.colors, [color]: true} | |
} | |
} | |
} | |
} | |
} | |
default: return state | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment