Last active
January 12, 2018 08:04
-
-
Save mweststrate/b1408d8117faf05e31d4742a34cfec7e to your computer and use it in GitHub Desktop.
immer producer with currying
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const byId = produce((draft, action) => { | |
switch (action.type) { | |
case RECEIVE_PRODUCTS: | |
action.products.forEach(product => { | |
draft[product.id] = product | |
}) | |
break | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment