From 13aed89d7b35d51bf713cd21a760822f8a67fcac Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Tue, 9 Jan 2024 15:05:19 +0100 Subject: [PATCH] docs: rename parameters related to feature name (#156) --- src/useFlag.ts | 8 ++++---- src/useVariant.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/useFlag.ts b/src/useFlag.ts index 6cf9709..8e13ea8 100644 --- a/src/useFlag.ts +++ b/src/useFlag.ts @@ -1,9 +1,9 @@ import { useContext, useEffect, useState, useRef } from 'react'; import FlagContext from './FlagContext'; -const useFlag = (name: string) => { +const useFlag = (featureName: string) => { const { isEnabled, client } = useContext(FlagContext); - const [flag, setFlag] = useState(!!isEnabled(name)); + const [flag, setFlag] = useState(!!isEnabled(featureName)); const flagRef = useRef(); flagRef.current = flag; @@ -11,7 +11,7 @@ const useFlag = (name: string) => { if (!client) return; const updateHandler = () => { - const enabled = isEnabled(name); + const enabled = isEnabled(featureName); if (enabled !== flagRef.current) { flagRef.current = enabled; setFlag(!!enabled); @@ -19,7 +19,7 @@ const useFlag = (name: string) => { }; const readyHandler = () => { - const enabled = isEnabled(name); + const enabled = isEnabled(featureName); flagRef.current = enabled; setFlag(enabled); }; diff --git a/src/useVariant.ts b/src/useVariant.ts index 7c1c01a..f99e18e 100644 --- a/src/useVariant.ts +++ b/src/useVariant.ts @@ -16,10 +16,10 @@ export const variantHasChanged = ( return !variantsAreEqual; }; -const useVariant = (name: string): Partial => { +const useVariant = (featureName: string): Partial => { const { getVariant, client } = useContext(FlagContext); - const [variant, setVariant] = useState(getVariant(name)); + const [variant, setVariant] = useState(getVariant(featureName)); const variantRef = useRef({ name: variant.name, enabled: variant.enabled, @@ -30,7 +30,7 @@ const useVariant = (name: string): Partial => { if (!client) return; const updateHandler = () => { - const newVariant = getVariant(name); + const newVariant = getVariant(featureName); if (variantHasChanged(variantRef.current, newVariant)) { setVariant(newVariant); variantRef.current = newVariant; @@ -38,7 +38,7 @@ const useVariant = (name: string): Partial => { }; const readyHandler = () => { - const variant = getVariant(name); + const variant = getVariant(featureName); variantRef.current.name = variant?.name; variantRef.current.enabled = variant?.enabled; setVariant(variant);