Skip to content
Shubham JangleResources
React

Explore topics

Feature Flag Component

Watch the walkthrough
Open on Instagram

Exercise: Build a feature-flag component

Implement a flag provider and a reusable Feature component that conditionally renders its children. Allow a fallback when the feature is disabled. Use a mock flag service returning a map of flag names to booleans.

Requirements

  • Distinguish flags still loading from a known false value; define the behavior for unknown flags.
  • Expose both a component API and a useFeatureFlag(name) hook backed by the same state.
  • Demonstrate a default disabled state, an enabled feature, and a fallback UI.
  • Keep server and initial client decisions consistent if adding server rendering.

Acceptance checks and discussion

Toggle a flag and confirm all consumers update. Simulate a failed flag request and verify the chosen defaults. Explain why hiding a client-side feature does not authorize or protect its backend endpoint.

The brief above is an original practice specification. The linked sandbox is supporting solution material and may implement a simpler subset of these requirements.

Supporting material