Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: convert FeatureFlag Index.js file to Index.tsx #17600

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@ import React, {
useEffect,
useRef,
useState,
ReactNode,
} from 'react';
import deprecate from '../../prop-types/deprecate';

interface FeatureFlagsProps {
children?: ReactNode;
flags?: Record<string, boolean>;
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
Expand All @@ -37,7 +48,7 @@ function FeatureFlags({
enableV12Overflowmenu = false,
enableTreeviewControllable = false,
enableExperimentalFocusWrapWithoutSentinels = false,
}) {
}: FeatureFlagsProps): JSX.Element {
const parentScope = useContext(FeatureFlagContext);
const [prevParentScope, setPrevParentScope] = useState(parentScope);

Expand Down Expand Up @@ -108,7 +119,11 @@ FeatureFlags.propTypes = {
* @param {Function} compare
* @param {Function} callback
*/
function useChangedValue(value, compare, callback) {
function useChangedValue<T>(
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);
Expand Down Expand Up @@ -163,7 +178,10 @@ function useFeatureFlags() {
* @param {object} b
* @returns {boolean}
*/
function isEqual(a, b) {
function isEqual(
a: Record<string, boolean>,
b: Record<string, boolean>
): boolean {
if (a === b) {
return true;
}
Expand Down
Loading