Answers for "immer.js reducer"

0

immer.js reducer

import produce from "immer"

const byId = produce((draft, action) => {
    switch (action.type) {
        case RECEIVE_PRODUCTS:
            action.products.forEach(product => {
                draft[product.id] = product
            })
    }
}, {})
Posted by: Guest on January-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language