From d3f1f8b906a8588c0f5a7998b831ee44a70dafeb Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Wed, 19 Apr 2023 21:23:49 +0200 Subject: [PATCH] Shaves off an easy 1.4kb win from the global package (#8382) --- packages/features/flags/context/provider.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/features/flags/context/provider.ts b/packages/features/flags/context/provider.ts index 9a8cb64e48..deb6adb5b5 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(null); +const FeatureContext = createContext(null); /** * Accesses the evaluated flags from context. @@ -21,7 +21,7 @@ const FeatureContext = React.createContext(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(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); }