firebase / firebase-tools-ui

A local-first UI for Firebase Emulator Suite.
https://firebase.googleblog.com/2020/05/local-firebase-emulator-ui.html
Apache License 2.0
262 stars 60 forks source link

Experiment flags #979

Closed jhuleatt closed 11 months ago

jhuleatt commented 11 months ago

Allow experiments set with firebase experiments:enable to be accessed by the emulator UI. Corresponding CLI PR: https://github.com/firebase/firebase-tools/pull/6169

The new useExperiment() hook will return a list of enabled experiments, so any component that wants to conditionally show UI based on an experiment flag can call this hook:

function ExperimentalFeatureUI() {
  const showNewFeature = useExperiment("pineapple-smoothie");

  if (showNewFeature === true) {
    return <h1>Hi, I am an experimental feature</h1>;
  } else {
    return null;
  }
}