Retry add JS view config for View

Summary: Adds the JavaScript view config for View

Reviewed By: TheSavior

Differential Revision: D15862368

fbshipit-source-id: 8a6a77cf57e84744044a2d6034aff2be6e600f5f
This commit is contained in:
Rick Hanlon
2019-07-22 09:30:31 -07:00
committed by Facebook Github Bot
parent 61b6c851c5
commit 42cf8a9241
4 changed files with 43 additions and 6 deletions
@@ -60,6 +60,7 @@ const ReactNativeViewViewConfigAndroid = {
},
validAttributes: {
hasTVPreferredFocus: true,
focusable: true,
nativeBackgroundAndroid: true,
nativeForegroundAndroid: true,
nextFocusDown: true,
@@ -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>>;
export default ((requireNativeComponent(
'RCTView',
): any): ViewNativeComponentType);
let NativeViewComponent;
let viewConfig;
// 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
+16 -1
View File
@@ -348,4 +348,19 @@ jest
.mock(
'../Libraries/Utilities/verifyComponentAttributeEquivalence',
() => function() {},
);
)
.mock('../Libraries/Components/View/ViewNativeComponent', () => {
const React = require('react');
const Component = class extends React.Component {
render() {
return React.createElement('View', this.props, this.props.children);
}
};
Component.displayName = 'View';
return {
__esModule: true,
default: Component,
};
});