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.

Children render callback #85

Description

@HHogg

Hi, would you be open to a PR that allows the render callback to be passed in as the children prop? This would allow people to keep the render logic together inside the render function.

The API I imagine it being like is something like...

render(){return(<FeatureFlagkey="Feature1">{(value)=>value ? <Feature1Component/> : <FallbackComponent/>}</FeatureFlag>);}

And this would also work for multivariant flags too...

render(){return(<FeatureFlagkey="Feature1">{(value)=>{switch(value){case1: return<Feature1Case1/>case2: return<Feature1Case2/>case3: return<Feature1Case3/>default: return<FallbackComponent/>}}}</FeatureFlag>);}

As FeatureFlag doesn't support any children at the moment, then it would not be a breaking change and could just be given the value.

I guess the change would be here, with something like ...

if(children){returnchildren(flagValue);}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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