Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hindmost/24de44c4cfd578f2c318689318505ce2 to your computer and use it in GitHub Desktop.
Save hindmost/24de44c4cfd578f2c318689318505ce2 to your computer and use it in GitHub Desktop.
cra-rich-chrome-ext article: src/reducers/marker.js - final edition
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