diff --git a/docs/reference/createPlugin-feature-flags.md b/docs/reference/createPlugin-feature-flags.md index d8ad043ddc..6c3a5f0bc5 100644 --- a/docs/reference/createPlugin-feature-flags.md +++ b/docs/reference/createPlugin-feature-flags.md @@ -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 ( + + ); +}; ``` [Back to References](README.md)