Created
August 11, 2020 18:11
-
-
Save hindmost/24de44c4cfd578f2c318689318505ce2 to your computer and use it in GitHub Desktop.
cra-rich-chrome-ext article: src/reducers/marker.js - final edition
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
import { | |
SET_ENABLED, SET_STATS, SET_ICONHASH | |
} from '../actions/marker'; | |
const initialState = { | |
enabled: false, | |
stats: false, | |
iconHash: '' | |
}; | |
export default function marker(state = initialState, action) { | |
const {type, data} = action; | |
switch (type) { | |
case SET_ENABLED: | |
return { | |
...state, | |
enabled: Boolean(data) | |
}; | |
case SET_STATS: | |
return { | |
...state, | |
stats: Array.isArray(data)? data.slice() : false | |
}; | |
case SET_ICONHASH: | |
return { | |
...state, | |
iconHash: data | |
}; | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment