mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
aa03c836b4
Summary: Migrates `View` to use `NativeComponentRegistry`, which enables configuring it to avoid reflection by using a static `ViewConfig`. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D25136054 fbshipit-source-id: f2abda1105bd2a8b396db6f1a640430b62bbcdaf
48 lines
1.4 KiB
JavaScript
48 lines
1.4 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
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
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 {type ViewProps as Props} from './ViewPropTypes';
|
|
import * as React from 'react';
|
|
|
|
const ViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.get<Props>(
|
|
'RCTView',
|
|
() =>
|
|
Platform.OS === 'android'
|
|
? ReactNativeViewViewConfigAndroid
|
|
: {uiViewClassName: 'RCTView'},
|
|
);
|
|
|
|
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>;
|