Skip to content

Commit 6fef480

Browse files
rickhanloniifacebook-github-bot
authored andcommitted
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
1 parent be07435 commit 6fef480

File tree

4 files changed

+99
-5
lines changed

4 files changed

+99
-5
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
* @format
9+
*/
10+
11+
'use strict';
12+
13+
const ReactNativeViewConfig = {
14+
uiViewClassName: 'RCTView',
15+
bubblingEventTypes: {
16+
topSelect: {
17+
phasedRegistrationNames: {
18+
bubbled: 'onSelect',
19+
captured: 'onSelectCapture',
20+
},
21+
},
22+
},
23+
directEventTypes: {
24+
topClick: {
25+
registrationName: 'onClick',
26+
},
27+
topContentSizeChange: {
28+
registrationName: 'onContentSizeChange',
29+
},
30+
topLoadingError: {
31+
registrationName: 'onLoadingError',
32+
},
33+
topLoadingFinish: {
34+
registrationName: 'onLoadingFinish',
35+
},
36+
topLoadingStart: {
37+
registrationName: 'onLoadingStart',
38+
},
39+
topMessage: {
40+
registrationName: 'onMessage',
41+
},
42+
topMomentumScrollBegin: {
43+
registrationName: 'onMomentumScrollBegin',
44+
},
45+
topMomentumScrollEnd: {
46+
registrationName: 'onMomentumScrollEnd',
47+
},
48+
topScroll: {
49+
registrationName: 'onScroll',
50+
},
51+
topScrollBeginDrag: {
52+
registrationName: 'onScrollBeginDrag',
53+
},
54+
topScrollEndDrag: {
55+
registrationName: 'onScrollEndDrag',
56+
},
57+
topSelectionChange: {
58+
registrationName: 'onSelectionChange',
59+
},
60+
},
61+
validAttributes: {
62+
hasTVPreferredFocus: true,
63+
nativeBackgroundAndroid: true,
64+
nativeForegroundAndroid: true,
65+
nextFocusDown: true,
66+
nextFocusForward: true,
67+
nextFocusLeft: true,
68+
nextFocusRight: true,
69+
nextFocusUp: true,
70+
},
71+
};
72+
73+
module.exports = ReactNativeViewConfig;

Libraries/Components/View/View.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'use strict';
1212

1313
const React = require('react');
14-
const ViewNativeComponent = require('./ViewNativeComponent');
14+
import ViewNativeComponent from './ViewNativeComponent';
1515

1616
import type {ViewProps} from './ViewPropTypes';
1717

Libraries/Components/View/ViewNativeComponent.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,34 @@
1111
'use strict';
1212

1313
const ReactNative = require('../../Renderer/shims/ReactNative');
14-
14+
const Platform = require('../../Utilities/Platform');
15+
const registerGeneratedViewConfig = require('../../Utilities/registerGeneratedViewConfig');
16+
const ReactNativeViewViewConfigAndroid = require('./ReactNativeViewViewConfigAndroid');
1517
const requireNativeComponent = require('../../ReactNative/requireNativeComponent');
1618

1719
import type {ViewProps} from './ViewPropTypes';
1820

1921
type ViewNativeComponentType = Class<ReactNative.NativeComponent<ViewProps>>;
2022

21-
const NativeViewComponent = requireNativeComponent('RCTView');
23+
let NativeViewComponent;
24+
let viewConfig;
25+
26+
// Only use the JS view config in DEV
27+
if (__DEV__) {
28+
// On Android, View extends the base component with additional view-only props
29+
// On iOS, the base component is View
30+
if (Platform.OS === 'android') {
31+
viewConfig = ReactNativeViewViewConfigAndroid;
32+
registerGeneratedViewConfig('RCTView', ReactNativeViewViewConfigAndroid);
33+
} else {
34+
viewConfig = {};
35+
registerGeneratedViewConfig('RCTView', {uiViewClassName: 'RCTView'});
36+
}
37+
38+
NativeViewComponent = 'RCTView';
39+
} else {
40+
NativeViewComponent = requireNativeComponent('RCTView');
41+
}
2242

23-
module.exports = ((NativeViewComponent: any): ViewNativeComponentType);
43+
export const __INTERNAL_VIEW_CONFIG = viewConfig;
44+
export default ((NativeViewComponent: any): ViewNativeComponentType);

Libraries/Utilities/verifyComponentAttributeEquivalence.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const getNativeComponentAttributes = require('../ReactNative/getNativeComponentA
1515
import type {ReactNativeBaseComponentViewConfig} from '../Renderer/shims/ReactNativeTypes';
1616
import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig';
1717

18-
const IGNORED_KEYS = ['transform'];
18+
const IGNORED_KEYS = ['transform', 'hitSlop'];
1919
/**
2020
* The purpose of this function is to validate that the view config that
2121
* native exposes for a given view manager is the same as the view config

0 commit comments

Comments
 (0)