# isEditableLaunchDarklyClient

Determine whether a LaunchDarkly SDK client is editable, meaning that it exposes methods to modify feature flags such as setFeatureFlags.

# Reference

const isEditable = isEditableLaunchDarklyClient(launchDarklyClient)

# Parameters

  • launchDarklyClient: A LaunchDarkly SDK client instance that is ready.

# Returns

A boolean indicating whether the LaunchDarkly client is editable.

# Usage

If you are using an editable LaunchDarkly client implementation such as the InMemoryLaunchDarklyClient or the LocalStorageLaunchDarklyClient, the isEditableLaunchDarklyClient function can be utilize to safely check if the client supports modifying feature flags at runtime.

import { isEditableLaunchDarklyClient, useFeatureFlag, useLaunchDarklyClient } from "@squide/firefly";
import { useCallback } from "react";

const enabled = useFeatureFlag("show-characters", false);
const launchDarklyClient = useLaunchDarklyClient();

const handleChange = useCallback(() => {
    if (isEditableLaunchDarklyClient(launchDarklyClient)) {
        launchDarklyClient.setFeatureFlags({
            "show-characters": !enabled,
        });
    }
}, [enabled, launchDarklyClient]);