Skip to content

Instantly share code, notes, and snippets.

@danrspencer
Created June 20, 2018 07:36
Show Gist options
  • Save danrspencer/b683c2298bbf29f5c275d5b5d38691e5 to your computer and use it in GitHub Desktop.
Save danrspencer/b683c2298bbf29f5c275d5b5d38691e5 to your computer and use it in GitHub Desktop.
Use lenses to update state in reducers
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