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.
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, thelaunchdarkly-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