[docs] updated with typescript definitions + code sample

This commit is contained in:
Bilawal Hameed
2020-03-26 12:22:01 +01:00
parent 79654e477e
commit 817c476050
+21 -3
View File
@@ -3,13 +3,31 @@
The `featureFlags` object passed to the `register` function makes it possible for plugins to register Feature Flags in Backstage for users to opt into. You can use this to split out logic in your code for manual A/B testing, etc.
```typescript
// This needs to be updated.
export type FeatureFlagsHooks = {
registerFeatureFlag(name: FeatureFlagName): void;
};
```
Then, later, if you want to check if the user has enabled them:
```typescript
// This needs to be updated.
```tsx
import React, { FC } from 'react';
import { Button } from '@material-ui/core';
import { featureFlagsApiRef, useApi } from '@backstage/core';
const ExampleButton: FC<{}> = () => {
const featureFlagsApi = useApi(featureFlagsApiRef);
const handleClick = () => {
featureFlagsApi.enable('enable-example-feature');
};
return (
<Button variant="contained" color="primary" onClick={handleClick}>
Enable the 'enable-example-feature' feature flag
</Button>
);
};
```
[Back to References](README.md)