Skip to content

Instantly share code, notes, and snippets.

@rohanBagchi
Created February 28, 2018 10:45
Show Gist options
  • Select an option

  • Save rohanBagchi/74948e956b94560bb441a3d87ec0419e to your computer and use it in GitHub Desktop.

Select an option

Save rohanBagchi/74948e956b94560bb441a3d87ec0419e to your computer and use it in GitHub Desktop.
import { createAction } from 'redux-actions';
import keyMirror from 'keymirror';
export const default_state = {
data: {},
ui: {}
};
export const ArticleActionTypes = keyMirror({
SET_ARTICLES: null,
});
export const setArticles = createAction(
ArticleActionTypes.SET_ARTICLES,
articles => ({ articles })
);
export default function reducer(state, action) {
state = state || default_state;
const { payload } = action;
switch (action.type) {
case ArticleActionTypes.SET_ARTICLES:
return {
...state,
data: {
...state.data,
articles: payload.articles
}
};
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment