From fbc643523b963a5b0bd433ae49718341d53e4e96 Mon Sep 17 00:00:00 2001 From: Nikhil Tomar Date: Mon, 30 Sep 2024 14:07:33 +0530 Subject: [PATCH 1/2] chore: remane file to .tsx to track change history --- .../react/src/components/FeatureFlags/{index.js => index.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/react/src/components/FeatureFlags/{index.js => index.tsx} (100%) diff --git a/packages/react/src/components/FeatureFlags/index.js b/packages/react/src/components/FeatureFlags/index.tsx similarity index 100% rename from packages/react/src/components/FeatureFlags/index.js rename to packages/react/src/components/FeatureFlags/index.tsx From eca9469db442dd4944264f1ae6fd69421b2411f0 Mon Sep 17 00:00:00 2001 From: Nikhil Tomar Date: Mon, 30 Sep 2024 16:36:30 +0530 Subject: [PATCH 2/2] fix: convers file to .tsx --- .../src/components/FeatureFlags/index.tsx | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/react/src/components/FeatureFlags/index.tsx b/packages/react/src/components/FeatureFlags/index.tsx index 4d1a270b3f2b..82bf5e873949 100644 --- a/packages/react/src/components/FeatureFlags/index.tsx +++ b/packages/react/src/components/FeatureFlags/index.tsx @@ -16,8 +16,19 @@ import React, { useEffect, useRef, useState, + ReactNode, } from 'react'; import deprecate from '../../prop-types/deprecate'; + +interface FeatureFlagsProps { + children?: ReactNode; + flags?: Record; + enableV12TileDefaultIcons?: boolean; + enableV12TileRadioIcons?: boolean; + enableV12Overflowmenu?: boolean; + enableTreeviewControllable?: boolean; + enableExperimentalFocusWrapWithoutSentinels?: boolean; +} /** * Our FeatureFlagContext is used alongside the FeatureFlags component to enable * or disable feature flags in a given React tree @@ -37,7 +48,7 @@ function FeatureFlags({ enableV12Overflowmenu = false, enableTreeviewControllable = false, enableExperimentalFocusWrapWithoutSentinels = false, -}) { +}: FeatureFlagsProps): JSX.Element { const parentScope = useContext(FeatureFlagContext); const [prevParentScope, setPrevParentScope] = useState(parentScope); @@ -108,7 +119,11 @@ FeatureFlags.propTypes = { * @param {Function} compare * @param {Function} callback */ -function useChangedValue(value, compare, callback) { +function useChangedValue( + value: T, + compare: (a: T, b: T) => boolean, + callback: (value: T) => void +) { const initialRender = useRef(false); const savedCallback = useRef(callback); const [prevValue, setPrevValue] = useState(value); @@ -163,7 +178,10 @@ function useFeatureFlags() { * @param {object} b * @returns {boolean} */ -function isEqual(a, b) { +function isEqual( + a: Record, + b: Record +): boolean { if (a === b) { return true; }