Skip to content

Scheduling infrastructure for absolutely everyone.

Shaves off an easy 1.4kb win from the global package (#8382)

Alex van Andeld3f1f8b906a8
diff --git a/packages/features/flags/context/provider.ts b/packages/features/flags/context/provider.ts
index 9a8cb64e481..deb6adb5b5f 100644
--- a/packages/features/flags/context/provider.ts
+++ b/packages/features/flags/context/provider.ts
@@ -1,4 +1,4 @@
-import * as React from "react";
+import { createContext, useContext, createElement } from "react";
import type { AppFlags } from "../config";
@@ -12,7 +12,7 @@ export type Flags = AppFlags;
/**
* Allows you to access the flags from context
*/
-const FeatureContext = React.createContext<Flags | null>(null);
+const FeatureContext = createContext<Flags | null>(null);
/**
* Accesses the evaluated flags from context.
@@ -21,7 +21,7 @@ const FeatureContext = React.createContext<Flags | null>(null);
* this component.
*/
export function useFlagMap() {
- const flagMapContext = React.useContext(FeatureContext);
+ const flagMapContext = useContext(FeatureContext);
if (flagMapContext === null) throw new Error("Error: useFlagMap was used outside of FeatureProvider.");
return flagMapContext as Flags;
}
@@ -52,5 +52,5 @@ export function useFlagMap() {
* so you might not need this at all._
*/
export function FeatureProvider<F extends Flags>(props: { value: F; children: React.ReactNode }) {
- return React.createElement(FeatureContext.Provider, { value: props.value }, props.children);
+ return createElement(FeatureContext.Provider, { value: props.value }, props.children);
}