Add JS view config for View

Summary: This diff adds the generated view config for View (in DEV)

Reviewed By: ejanzer

Differential Revision: D15780039

fbshipit-source-id: 1ec8ed1b57fd2341552746051980129848cb8e85
This commit is contained in:
Rick Hanlon
2019-06-17 10:46:38 -07:00
committed by Facebook Github Bot
parent be07435e6a
commit 6fef48096d
4 changed files with 99 additions and 5 deletions
@@ -0,0 +1,73 @@
/**
* 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
* @format
*/
'use strict';
const ReactNativeViewConfig = {
uiViewClassName: 'RCTView',
bubblingEventTypes: {
topSelect: {
phasedRegistrationNames: {
bubbled: 'onSelect',
captured: 'onSelectCapture',
},
},
},
directEventTypes: {
topClick: {
registrationName: 'onClick',
},
topContentSizeChange: {
registrationName: 'onContentSizeChange',
},
topLoadingError: {
registrationName: 'onLoadingError',
},
topLoadingFinish: {
registrationName: 'onLoadingFinish',
},
topLoadingStart: {
registrationName: 'onLoadingStart',
},
topMessage: {
registrationName: 'onMessage',
},
topMomentumScrollBegin: {
registrationName: 'onMomentumScrollBegin',
},
topMomentumScrollEnd: {
registrationName: 'onMomentumScrollEnd',
},
topScroll: {
registrationName: 'onScroll',
},
topScrollBeginDrag: {
registrationName: 'onScrollBeginDrag',
},
topScrollEndDrag: {
registrationName: 'onScrollEndDrag',
},
topSelectionChange: {
registrationName: 'onSelectionChange',
},
},
validAttributes: {
hasTVPreferredFocus: true,
nativeBackgroundAndroid: true,
nativeForegroundAndroid: true,
nextFocusDown: true,
nextFocusForward: true,
nextFocusLeft: true,
nextFocusRight: true,
nextFocusUp: true,
},
};
module.exports = ReactNativeViewConfig;
+1 -1
View File
@@ -11,7 +11,7 @@
'use strict';
const React = require('react');
const ViewNativeComponent = require('./ViewNativeComponent');
import ViewNativeComponent from './ViewNativeComponent';
import type {ViewProps} from './ViewPropTypes';
@@ -11,13 +11,34 @@
'use strict';
const ReactNative = require('../../Renderer/shims/ReactNative');
const Platform = require('../../Utilities/Platform');
const registerGeneratedViewConfig = require('../../Utilities/registerGeneratedViewConfig');
const ReactNativeViewViewConfigAndroid = require('./ReactNativeViewViewConfigAndroid');
const requireNativeComponent = require('../../ReactNative/requireNativeComponent');
import type {ViewProps} from './ViewPropTypes';
type ViewNativeComponentType = Class<ReactNative.NativeComponent<ViewProps>>;
const NativeViewComponent = requireNativeComponent('RCTView');
let NativeViewComponent;
let viewConfig;
module.exports = ((NativeViewComponent: any): ViewNativeComponentType);
// Only use the JS view config in DEV
if (__DEV__) {
// On Android, View extends the base component with additional view-only props
// On iOS, the base component is View
if (Platform.OS === 'android') {
viewConfig = ReactNativeViewViewConfigAndroid;
registerGeneratedViewConfig('RCTView', ReactNativeViewViewConfigAndroid);
} else {
viewConfig = {};
registerGeneratedViewConfig('RCTView', {uiViewClassName: 'RCTView'});
}
NativeViewComponent = 'RCTView';
} else {
NativeViewComponent = requireNativeComponent('RCTView');
}
export const __INTERNAL_VIEW_CONFIG = viewConfig;
export default ((NativeViewComponent: any): ViewNativeComponentType);
@@ -15,7 +15,7 @@ const getNativeComponentAttributes = require('../ReactNative/getNativeComponentA
import type {ReactNativeBaseComponentViewConfig} from '../Renderer/shims/ReactNativeTypes';
import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig';
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