immer js reducer

Solutions on MaxInterview for immer js reducer by the best coders in the world

showing results for - "immer js reducer"
Michela
02 Oct 2019
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