1import produce from "immer"
2
3const byId = produce((draft, action) => {
4 switch (action.type) {
5 case RECEIVE_PRODUCTS:
6 action.products.forEach(product => {
7 draft[product.id] = product
8 })
9 }
10}, {})
11