flagr-feature-react
v0.1.3
Published
react module for using flagr-feature-typescript
Downloads
342
Readme
flagr-feature-react
Usage
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'}
</>
);
};
Installation
Requires npm 7
npm install
Development
npm run dev
Deployment
npm run build
Publishing
This is handled by GitHub actions