Skip to content

Does promap have to return another hook? #5

@skokenes

Description

@skokenes

Looking for some feedback here on a potential feature I might add to a fork, but I'm not sure if it makes sense since I'm new to lenses.

In this implementation of useProfunctorState, promap always returns a new ProfunctorState which is reliant on a hook. This is nice for defining lenses in children components.

But I am having trouble using it to dynamically create lenses in a single component. There are scenarios where I might want to use lenses "on the fly" inside a component, without creating a new hook but rather relying on the underlying hook of the parent profunctor. Like perhaps I want to create a profunctor for every item in a list of variable size. This won't work because you can't create hooks this way, but I don't really want to create a hook. I want to leverage the existing hook, but lens it without creating a new hook.

My questions are:
a) is this even a good idea to do, or does another architecture make more sense?
b) is it possible today given the existing API in some way that I'm not seeing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions