Skip to content

Commit

Permalink
Add useFeatureFlag to esm-react-utils public exports (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandones authored Jul 18, 2023
1 parent 1148f7b commit 2dcac98
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/framework/esm-framework/docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@

- [getFeatureFlag](API.md#getfeatureflag)
- [registerFeatureFlag](API.md#registerfeatureflag)
- [useFeatureFlag](API.md#usefeatureflag)

### Framework Functions

Expand Down Expand Up @@ -2633,6 +2634,39 @@ It can then be used to turn on or off features in the code.

___

### useFeatureFlag

**useFeatureFlag**(`flagName`): `boolean`

Use this function to tell whether a feature flag is toggled on or off.

Example:

```tsx
import { useFeatureFlag } from "@openmrs/esm-react-utils";

export function MyComponent() {
const isMyFeatureFlagOn = useFeatureFlag("my-feature-flag");
return <>{isMyFeatureFlagOn && <ExperimentalFeature />}</>;
}
```

#### Parameters

| Name | Type |
| :------ | :------ |
| `flagName` | `string` |

#### Returns

`boolean`

#### Defined in

[packages/framework/esm-react-utils/src/useFeatureFlag.ts:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-react-utils/src/useFeatureFlag.ts#L19)

___

## Framework Functions

### getAsyncExtensionLifecycle
Expand Down
1 change: 1 addition & 0 deletions packages/framework/esm-react-utils/src/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from "./useConnectivity";
export * from "./usePatient";
export * from "./useExtensionSlotMeta";
export * from "./useExtensionStore";
export * from "./useFeatureFlag";
export * from "./useLayoutType";
export * from "./useLocations";
export * from "./useOnClickOutside";
Expand Down

0 comments on commit 2dcac98

Please sign in to comment.