TrueCar / react-launch-darkly

Simple component helpers to support LaunchDarkly in your React app.
MIT License
76 stars 20 forks source link

Expose ldClientWrapper to subscribe to the same ldClient events #109

Open rrivem opened 4 years ago

rrivem commented 4 years ago

We're using the FeatureFlag to render components based on LD flags and works sharp.

But now we need to know if we need to avoid rendering a whole tree based on flags and other conditions.

We tried using ldclient-js directly, but the initialize seems to be affecting the FeatureFlag rendered items we have already and not being updated when a flag changes.

We think we could leverage this by having access to the ldClientWrapper to have access to the same ldClient instance used on components

sethbattin commented 4 years ago

Hi @rrivem, just to clarify the issue you're having: you need to know the value of a flag for a major section of your component tree, and the delay in loading the flags is a problem because it briefly renders the wrong content?

If so, perhaps you might benefit from the server-side rendering section of our readme. It describes how to initialize the js client with a previously-loaded set of flag values. This set of values can come from anywhere (webserver, etc) that knows the individual session's unique identifier (the same one you pass into the library), and can load them while serving your initial browser content. Then when the javascript library runs, it will use those values until it gets updates from launchdarkly's service via the js client. Launch darkly also provides useful local proxies for their service, to make certain server response time is minimal even when waiting for their data.

I hope this helps; if not please post as many details as you can so we can figure out how to solve it.