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

Description
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 (
<FeatureFlag key="Feature1">
{ (value) => value
? <Feature1Component />
: <FallbackComponent />
}
</FeatureFlag>
);
}
And this would also work for multivariant flags too...
render() {
return (
<FeatureFlag key="Feature1">
{ (value) => {
switch (value) {
case 1: return <Feature1Case1 />
case 2: return <Feature1Case2 />
case 3: 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) {
return children(flagValue);
}