Function createLDReactProviderWithClient

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

    Parameters

    Returns React.FC<{
        children: React.ReactNode;
    }>

    The LaunchDarkly React Client provider.

    Remarks

    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.

    Example

    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);

    See

Generated using TypeDoc