Files
react-native/Libraries/NativeComponent/ViewConfigIgnore.js
T
Ramanpreet Nara e254073b17 Update ViewConfigIgnore comment
Summary:
This comment was out of date.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D34113966

fbshipit-source-id: 0768baa9238736aea26e354792096fea6bb7fcdb
2022-02-10 08:47:22 -08:00

54 lines
1.5 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
import Platform from '../Utilities/Platform';
const ignoredViewConfigProps = new WeakSet<{...}>();
/**
* Decorates ViewConfig values that are dynamically injected by the library,
* react-native-gesture-handler. (T45765076)
*/
export function DynamicallyInjectedByGestureHandler<T: {...}>(object: T): T {
ignoredViewConfigProps.add(object);
return object;
}
/**
* On iOS, ViewManager event declarations generate {eventName}: true entries
* in ViewConfig valueAttributes. These entries aren't generated for Android.
* This annotation allows Static ViewConfigs to insert these entries into
* iOS but not Android.
*
* In the future, we want to remove this platform-inconsistency.
* This annotation also allows us to safely test this removal by setting
* global.RN$ViewConfigEventValidAttributesDisabled = true server-side.
*
* TODO(T110872225): Remove this logic, after achieving platform-consistency
*/
export function ConditionallyIgnoredEventHandlers<T: {[name: string]: true}>(
value: T,
): T | void {
if (
Platform.OS === 'ios' &&
!(global.RN$ViewConfigEventValidAttributesDisabled === true)
) {
return value;
}
return undefined;
}
export function isIgnored(value: mixed): boolean {
if (typeof value === 'object' && value != null) {
return ignoredViewConfigProps.has(value);
}
return false;
}