[docs] updated with typescript definitions + code sample
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user