Skip to content
This repository was archived by the owner on Dec 7, 2022. It is now read-only.
This repository was archived by the owner on Dec 7, 2022. It is now read-only.

Expose a higher-order component version of FeatureFlag. #33

@threehams

Description

@threehams

The current API uses a component and callback which essentially forces the use of a class component. This is fine for smaller changes, but it doesn't compose well with other React HOC-based libraries.

An example with code splitting and conditional data fetching:

const CardGroup = compose(
  withFeatureFlag("useNewCard"),
  withRouter,
  fetchData("cards", props => ({ id: props.params.postId })),
  branch( // from recompose library
    props => props.featureFlags.useNewCard === "A",
    renderComponent(AsyncCardA), // code split
  ),
)(AsyncCardB); // code split

This can allow the A/B test to be completely transparent to the wrapped component, and it can be easily added or removed without adding custom wrapper components.

This should be possible to do while sharing code with the existing component, possibly as a simple wrapper.

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