Skip to content

Context Transform #12234

@sebmarkbage

Description

@sebmarkbage

With the new context API it is really bulky to create a middle man that consumes one context value, transforms it and provides another one. You have to create many components and store an intermediate state to avoid rerendering the provider if the input is unchanged.

We could have a convenience API for this use case.

function transform(inputValue) {
  return [...inputValue, extraData];
}

<Context.Middleware transform={transform}>{children}</Context.Middleware>

cc @acdlite

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions