Skip to content

Instantly share code, notes, and snippets.

View loopdream's full-sized avatar

Dom Geargeoura loopdream

View GitHub Profile
@loopdream
loopdream / react-feature-flags.js
Created January 11, 2024 14:29 — forked from sergiodxa/react-feature-flags.js
React feature flags context, custom hook, hoc and render prop
import React from "react";
const FeatureFlags = React.createContext(null);
export function FeatureProvider({ features = null, children }) {
if (features === null || typeof features !== "object") {
throw new TypeError("The features prop must be an object or an array.");
}
return (
<FeatureFlags.Provider value={features}>{children}</FeatureFlags.Provider>