Files
react-native/Libraries/Components/View/ViewNativeComponent.js
T
Tim Yung f598dd0ee3 RN: Create Experiment for collapsable (iOS)
Summary:
Sets up an experiment that enables `collapsable` in Fabric for iOS. This will enable us to validate with production data that enabling the use of this prop does not cause unexpected regressions.

Changelog:
[internal]

Reviewed By: mdvacca

Differential Revision: D27987619

fbshipit-source-id: 9b1c0ff45bed09b1e72ad7d9c782f07bb4211cc6
2021-04-25 01:17:55 -07:00

56 lines
1.8 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its 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-local
* @format
*/
import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import Platform from '../../Utilities/Platform';
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid';
import ViewInjection from './ViewInjection';
import {type ViewProps as Props} from './ViewPropTypes';
import * as React from 'react';
import ReactNativeViewConfigRegistry from '../../Renderer/shims/ReactNativeViewConfigRegistry';
const ViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.get<Props>(
'RCTView',
() =>
Platform.OS === 'android'
? ReactNativeViewViewConfigAndroid
: {uiViewClassName: 'RCTView'},
);
if (Platform.OS === 'ios') {
if (ViewInjection.unstable_enableCollapsable) {
const viewConfig = ReactNativeViewConfigRegistry.get('RCTView');
// $FlowFixMe - Yes, knowingly writing to a read-only property.
viewConfig.validAttributes.collapsable = true;
}
}
interface NativeCommands {
+hotspotUpdate: (
viewRef: React.ElementRef<HostComponent<mixed>>,
x: number,
y: number,
) => void;
+setPressed: (
viewRef: React.ElementRef<HostComponent<mixed>>,
pressed: boolean,
) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
supportedCommands: ['hotspotUpdate', 'setPressed'],
});
export default ViewNativeComponent;
export type ViewNativeComponentType = HostComponent<Props>;