Use JS ViewConfig for View

Summary: Rick manually created view config in JS for View; adding some missing attributes/events and using this instead of `requireNativeComponent`

Reviewed By: rickhanlonii

Differential Revision: D15488008

fbshipit-source-id: 48e925ec0ca2aeba9e6cc66edef0b70ee1c94d27
This commit is contained in:
Emily Janzer
2019-05-28 10:22:43 -07:00
committed by Facebook Github Bot
parent bd3023abea
commit 77a6617a39
3 changed files with 63 additions and 8 deletions
@@ -10,12 +10,12 @@
'use strict';
const ReactNativeViewConfigRegistry = require('ReactNativeViewConfigRegistry');
const verifyComponentAttributeEquivalence = require('verifyComponentAttributeEquivalence');
const ReactNativeViewConfig = {
uiViewClassName: 'RCTView',
baseModuleName: null,
Manager: 'ViewManager',
Commands: {},
Constants: {},
bubblingEventTypes: {
topBlur: {
phasedRegistrationNames: {
@@ -53,6 +53,12 @@ const ReactNativeViewConfig = {
captured: 'onPressCapture',
},
},
topSelect: {
phasedRegistrationNames: {
bubbled: 'onSelect',
captured: 'onSelectCapture',
},
},
topSubmitEditing: {
phasedRegistrationNames: {
bubbled: 'onSubmitEditing',
@@ -85,6 +91,9 @@ const ReactNativeViewConfig = {
},
},
directEventTypes: {
performAction: {
registrationName: 'onAccessibilityAction',
},
topAccessibilityAction: {
registrationName: 'onAccessibilityAction',
},
@@ -94,12 +103,48 @@ const ReactNativeViewConfig = {
topAccessibilityTap: {
registrationName: 'onAccessibilityTap',
},
topClick: {
registrationName: 'onClick',
},
topContentSizeChange: {
registrationName: 'onContentSizeChange',
},
topLayout: {
registrationName: 'onLayout',
},
topLoadingError: {
registrationName: 'onLoadingError',
},
topLoadingFinish: {
registrationName: 'onLoadingFinish',
},
topLoadingStart: {
registrationName: 'onLoadingStart',
},
topMagicTap: {
registrationName: 'onMagicTap',
},
topMessage: {
registrationName: 'onMessage',
},
topMomentumScrollBegin: {
registrationName: 'onMomentumScrollBegin',
},
topMomentumScrollEnd: {
registrationName: 'onMomentumScrollEnd',
},
topScroll: {
registrationName: 'onScroll',
},
topScrollBeginDrag: {
registrationName: 'onScrollBeginDrag',
},
topScrollEndDrag: {
registrationName: 'onScrollEndDrag',
},
topSelectionChange: {
registrationName: 'onSelectionChange',
},
},
validAttributes: {
accessibilityActions: true,
@@ -156,6 +201,7 @@ const ReactNativeViewConfig = {
flexGrow: true,
flexShrink: true,
flexWrap: true,
hasTVPreferredFocus: true,
height: true,
hitSlop: {diff: (require('../../Utilities/differ/insetsDiffer'): any)},
importantForAccessibility: true,
@@ -174,8 +220,15 @@ const ReactNativeViewConfig = {
maxWidth: true,
minHeight: true,
minWidth: true,
nativeBackgroundAndroid: true,
nativeForegroundAndroid: true,
nativeID: true,
needsOffscreenAlphaCompositing: true,
nextFocusDown: true,
nextFocusForward: true,
nextFocusLeft: true,
nextFocusRight: true,
nextFocusUp: true,
onAccessibilityAction: true,
onAccessibilityEscape: true,
onAccessibilityTap: true,
@@ -326,4 +379,8 @@ const ReactNativeViewConfig = {
},
};
verifyComponentAttributeEquivalence('RCTView', ReactNativeViewConfig);
ReactNativeViewConfigRegistry.register('RCTView', () => ReactNativeViewConfig);
module.exports = ReactNativeViewConfig;
@@ -12,12 +12,10 @@
const ReactNative = require('../../Renderer/shims/ReactNative');
const requireNativeComponent = require('../../ReactNative/requireNativeComponent');
import type {ViewProps} from './ViewPropTypes';
type ViewNativeComponentType = Class<ReactNative.NativeComponent<ViewProps>>;
const NativeViewComponent = requireNativeComponent('RCTView');
require('ReactNativeViewViewConfig');
module.exports = ((NativeViewComponent: any): ViewNativeComponentType);
module.exports = (('RCTView': any): ViewNativeComponentType);
@@ -14,7 +14,7 @@ const getNativeComponentAttributes = require('../ReactNative/getNativeComponentA
import type {ReactNativeBaseComponentViewConfig} from '../Renderer/shims/ReactNativeTypes';
const IGNORED_KEYS = ['transform'];
const IGNORED_KEYS = ['transform', 'hitSlop'];
/**
* The purpose of this function is to validate that the view config that
* native exposes for a given view manager is the same as the view config