feature gate documentation
Feature Flags System
The hook lets you use feature flags to hide paid functionality.
Overview
The hook returns an object with a boolean enabled field for the specified flag.
Usage
- Add a flag in
constants/features.js. - Activate the flag: PlanFeatureValue — add an option on the company page in Manage, featureNames — add the flag in the modal on the Manage Users page
Client Components
- Simple hide/show of a UI element
// @flowimport { useFeature } from 'feature-gate';import { featureNames } from '@power-rent/constants/features';
function MapButton() { const { enabled: isVehicleMapEnabled } = useFeature(featureNames.vehicleMap);
if (!isVehicleMapEnabled) return null;
return <button>Open Map</button>;}Notes:
- These components must be wrapped by
FeatureGateProvider(already done app-wide incomponents/Gate/index.js). - Feature names must match keys configured in
constants/features.jsor provided by your remote flags provider.