flagr-feature-react
Version:
react module for using flagr-feature-typescript
61 lines (44 loc) • 953 B
Markdown
//img.shields.io/npm/v/flagr-feature-react?color=CC3534&logo=npm)](https://www.npmjs.com/package/flagr-feature-react)
```tsx
import { useFlagr, FlagrContextProvider } from 'flagr-feature-react';
const ID = 'user_123';
const SOME_URL = 'flagrUrl';
const APP_TAGS = ['local'];
const OPTIONAL_CONTEXT = undefined;
const MyApp = () => (
<FlagrContextProvider
flagrUrl={SOME_URL}
tags={APP_TAGS}
context={OPTIONAL_CONTEXT}
id={ID}
>
<MyComponent />
</FlagrContextProvider>
);
const MyComponent = () => {
const { match, loaded } = useFlagr();
return (
<>
{!loaded && 'loading'}
{loaded && match?.('someFeature') ? 'new hotness' : 'old and busted'}
</>
);
};
```
Requires npm 7
```bash
npm install
```
```bash
npm run dev
```
```bash
npm run build
```
This is handled by GitHub actions
[![image](https: