Created
June 20, 2018 07:36
-
-
Save danrspencer/b683c2298bbf29f5c275d5b5d38691e5 to your computer and use it in GitHub Desktop.
Use lenses to update state in reducers
This file contains hidden or 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 update = (lensGenerator, func) => (state, payload) => | |
over( | |
lensGenerator(payload), | |
obj => ({ ...obj, ...func(payload, obj, state) }), | |
state | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment