Skip to content

Exploring use cases of lenses, especially for state management (and how they might be used with the React Hooks API)

Notifications You must be signed in to change notification settings

ccfp/lenses-and-hooks

Repository files navigation

Lenses 👓 & Hooks 🎣

🎯 Ambitious goals: The aim of this session/workshop/whatever-it-is is to implement a custom React hook that will utilize lenses for state management. The inspiration is André Staltz's use-profunctor-state library. Here's the accompanying talk: "Profunctor Optics for State Management".

To be honest, I don't really know what profunctors are all about (and maybe André doesn't either?), but I think we should be able to implement something similar with regular old lenses brought in from ramda or partial.lenses. We could also try implementing our own set/view/over functions from scratch (or, mostly from scratch, as it probably would be easier to rely on optics implementations from one of the above libraries).

The idea is that you can replace Redux with a top-level state object and use lenses to get and set from state. At least, that's the promise, but I don't know—I am still learning Redux so we'll see how this goes 😉.

About

Exploring use cases of lenses, especially for state management (and how they might be used with the React Hooks API)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published