mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
971ba5c26b
Summary:
# Problem
I removed the {eventName}: true entries from ViewConfigs validAttributes in D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a). These entries were iOS-only. I removed them to achieve platform-consistency in native ViewConfigs.
This change broke the onLayout event for all React Native components. So, I reverted D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a) for native ViewConfigs server-side. But I never got around to reverting D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a) for static ViewConfigs.
# Changes
This diff reverts D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a) for Static ViewConfigs, with server-side gating.
Now, these {eventName}: true ViewConfig validAttribute will be inserted into all view configs (static and native) **by default**.
Calling RCTDisableViewConfigEventValidAttributes(YES) on iOS will remove {eventName}: true ViewConfig ValidAttributes entries from Static ViewConfigs. (Previously, this method only removed the entries from native ViewConfigs).
https://www.internalfb.com/code/fbsource/[6615b0675bdf]/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/Exported/FBReactModule.mm?lines=344
Changelog: [Internal]
Reviewed By: yungsters
Differential Revision: D33933403
fbshipit-source-id: 17823ed99f97d7851f04e5cdab9c95667df13253
56 lines
1.7 KiB
JavaScript
56 lines
1.7 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 events declarations generate {eventName}: true entries
|
|
* in ViewConfig valueAttributes. In our Static ViewConfig infra, we generate
|
|
* these {eventName}: true entries during runtime by inspecting a ViewConfig's
|
|
* bubblingEventTypes, and directEventTypes.
|
|
*
|
|
* However, not all event declarations generate these {eventName}: true entries.
|
|
* So, the ViewConfig infra generates extra {eventName}: true entries for some
|
|
* events. These extra entries are harmless. So, the logic below makes the ViewConfig
|
|
* Validator ignore all extra {eventName}: true entries in static ViewConfig
|
|
* validAttributes.
|
|
*
|
|
* TODO(T110872225): Remove this logic
|
|
*/
|
|
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;
|
|
}
|