How to use the launchdarkly-react-client-sdk.withLDProvider function in launchdarkly-react-client-sdk

To help you get started, we’ve selected a few launchdarkly-react-client-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linode / manager / packages / manager / src / containers / withFeatureFlagProvider.container.ts View on Github external
import { useLDClient, withLDProvider } from 'launchdarkly-react-client-sdk';

import { LAUNCH_DARKLY_API_KEY } from 'src/constants';

export { useLDClient };

/**
 * only wrap the component in the HOC if we've passed
 * the Launch Darkly API key as an environment variable.
 *
 * Otherwise, we can't communicate with the Launch Darkly API
 * which makes this HOC have no effect - just return the component
 * as normal in this case
 */
const featureFlagProvider = LAUNCH_DARKLY_API_KEY
  ? withLDProvider({
      clientSideID: LAUNCH_DARKLY_API_KEY,
      /**
       * Initialize the app with an anonymous user.
       */
      user: {
        key: 'anonymous',
        anonymous: true
      }
    })
  : (component: React.ComponentType) => component;

export default featureFlagProvider;

launchdarkly-react-client-sdk

LaunchDarkly SDK for React

Apache-2.0
Latest version published 2 months ago

Package Health Score

86 / 100
Full package analysis

Popular launchdarkly-react-client-sdk functions