LaunchDarkly is an awesome feature flag management platform that allows for simple control of flags across multiple environments, allowing us to non-ironically test in production. LaunchDarkly supports most popular web languages, and there are a bunch of 3rd party libraries out there as well to make life easier for developers. For React applications, I've tried a few different routes for handling the client side feature flags, each with their own trade off of benefits and limitations.
LaunchDarkly component, throw your new functionality in a
FeatureFlag component, and you're good to go. As expected though, the price of this simplicity is that it is more challenging to custom logic based on flags or on events such as a flag change.
Another great option is LaunchDarkly's own React SDK. This library provides a set of higher order components that initialize the LaunchDarkly client and then pass the flags in as
props wherever needed. One big benefit of this library is that the
ldClient is passed into
props along with the flags, allowing direct access to the client and all accompanying functionality. This library is a little less plug-and-play than TrueCar's, but the easy direct access to the client allows for easier implementation of custom logic.
FeatureFlag component for easy conditional rendering and a HOC for passing in the client and flags to whatever component needs them. When rolling your own, there is additional effort required to configure the flag change subscriptions which the above libraries do automatically, and of course there is more work in maintaining a custom implementation as opposed to using a library.
~ MADReturn to Blog