Skip to content

Instantly share code, notes, and snippets.

@itaditya
Created September 28, 2020 04:33
Show Gist options
  • Select an option

  • Save itaditya/c9281d4393dbca3d366b14d6f296d13b to your computer and use it in GitHub Desktop.

Select an option

Save itaditya/c9281d4393dbca3d366b14d6f296d13b to your computer and use it in GitHub Desktop.
(Blog) Build a Redux hooked app
case ACTIONS.LOAD_MENU: {
const { menu } = action.payload;
const menuById = {};
menu.forEach((item) => {
menuById[item.id] = item;
});
const allMenuId = menu.map((item) => item.id);
const vegMenuId = menu
.filter((item) => item.diet === "veg")
.map((item) => item.id);
return {
...state,
menuById,
menuIdList: {
all: allMenuId,
veg: vegMenuId,
},
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment