Skip to content
This repository was archived by the owner on Dec 7, 2022. It is now read-only.
This repository was archived by the owner on Dec 7, 2022. It is now read-only.

Support for hooks? #119

@Brianzchen

Description

@Brianzchen

Any plans to support hooks so we can simplify our component tree or create easier composition of multiple feature flags? This feature has been around for more than a year, so it would be really great to support the modern standard.

Support would have to be bumped from React v16.3.0 to v16.8.0.

Suggested api

useFeatureFlag(flag: string): boolean | undefined
// undefined === 'loading'

Usage

import React from 'react';
import { useFeatureFlag } from 'react-launch-darkly';

const Comp = () => {
  const isAnniversaryCallTask = useFeatureFlag('anniversary-call-task');

  return (
    <div>
      {isAnniversaryCallTask ? 'Flag on' : 'Flag off'}
    </div>
  );
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions