@launchdarkly/react-sdk - v4.2.3
    Preparing search index...

    Function createLDReactProviderWithClient

    • Creates a new LaunchDarkly React provider wrapping an existing client instance.

      Parameters

      Returns FC<{ children: ReactNode }>

      The LaunchDarkly React Client provider.

      NOTE: We recommend using the factory function createLDReactProvider instead of this function if you can.

      This factory function is provided to allow the caller to use an existing client instance. When using this function, the caller is responsible for calling client.start() before or after mounting.

      import { createClient, createLDReactProviderWithClient, initLDReactContext } from '@launchdarkly/react-sdk';

      const client = createClient(clientSideID, context);
      client.start();
      const LDProvider = createLDReactProviderWithClient(client);

      For multiple client instances, pass a custom React context:

      const ReactContext = initLDReactContext();
      const LDProvider = createLDReactProviderWithClient(client, ReactContext);