1.1.0 • Published 9 months ago

@attivo/hooks v1.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

@attivo/hooks

A collection of React hooks for Attivø.

Installation

npm install @attivo/hooks

Usage

useFeatureFlags

useFeatureFlags is a React hook that integrates with Attivø's feature flag system. It provides real-time feature flag state management in your React components.

import { useFeatureFlags } from '@attivo/hooks';

function MyComponent() {
  const isFeatureEnabled = useFeatureFlags('my-feature', false);

  return (
    <div>
      {isFeatureEnabled ? (
        <p>Feature is enabled!</p>
      ) : (
        <p>Feature is disabled</p>
      )}
    </div>
  );
}

Parameters

  • key (string): The feature flag identifier
  • defaultValue (boolean, optional): Default state of the feature flag. Defaults to false

Returns

  • boolean: The current state of the feature flag

Feature Flag Resolution

The hook resolves feature flags in the following order: 1. Window-level flags 2. Session storage 3. Local storage 4. Default value 5. false (fallback)

1.1.0

9 months ago

1.0.1

10 months ago

1.0.0

10 months ago