launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
86 stars 68 forks source link

Pass in client #105

Closed TimboTambo closed 2 years ago

TimboTambo commented 2 years ago

Requirements

Related issues

Somewhat related to Issue 56

Describe the solution you've provided

In order to be able to initialise a single instance of the LD client and share it between multiple, independent React trees, we require the ability to pass in the client (or a promise that resolves to the client) into the provider, rather than have it initialise the LD client for us.

This PR adds the client as an optional prop to the provider so that it can use this instance if passed in, otherwise create one.

Describe alternatives you've considered

Using the launchdarkly-js-client-sdk directly, however, the launchdarkly-react-client-sdk is already used extensively so this would require a large change, and the helpers provided by this library are extremely useful.

We could also use our own fork, but it would be great to benefit from other updates to this library.

Additional context

N/A

TimboTambo commented 2 years ago

@yusinto did you have any more thoughts on this PR or are you happy to approve it?

bwoskow-ld commented 2 years ago

This is now available in 2.24.0. Thank you for the contribution!