Skip to content

Commit

Permalink
Use requireNativeComponent in View.js.
Browse files Browse the repository at this point in the history
Summary: public
In a previous diff I've removed a need for using View attributes in requireNativeComponent. Thanks to that we can now use requireNativeComponent in View module. In a follow up diff I'll be getting rid of ReactNativeViewAttributes.

Reviewed By: sahrens

Differential Revision: D2676088

fb-gh-sync-id: d5d6e50f4629bd7982b90f3496e1fd22078e96a8
  • Loading branch information
kmagiera authored and facebook-github-bot-0 committed Nov 20, 2015
1 parent 0d17d6a commit 7cd7591
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 6 additions & 5 deletions Libraries/Components/View/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
var StyleSheetPropType = require('StyleSheetPropType');
var ViewStylePropTypes = require('ViewStylePropTypes');

var createReactNativeComponentClass = require('createReactNativeComponentClass');
var requireNativeComponent = require('requireNativeComponent');

var stylePropType = StyleSheetPropType(ViewStylePropTypes);

Expand Down Expand Up @@ -316,11 +316,12 @@ var View = React.createClass({
},
});

var RCTView = createReactNativeComponentClass({
validAttributes: ReactNativeViewAttributes.RCTView,
uiViewClassName: 'RCTView',
var RCTView = requireNativeComponent('RCTView', View, {
nativeOnly: {
nativeBackgroundAndroid: true,
}
});
RCTView.propTypes = View.propTypes;

if (__DEV__) {
var viewConfig = RCTUIManager.viewConfigs && RCTUIManager.viewConfigs.RCTView || {};
for (var prop in viewConfig.nativeProps) {
Expand Down
2 changes: 0 additions & 2 deletions Libraries/ReactIOS/verifyPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
'use strict';

var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
var View = require('View');

export type ComponentInterface = ReactClass<any, any, any> | {
name?: string;
Expand Down Expand Up @@ -40,7 +39,6 @@ function verifyPropTypes(
var nativeProps = viewConfig.NativeProps;
for (var prop in nativeProps) {
if (!componentInterface.propTypes[prop] &&
!View.propTypes[prop] &&
!ReactNativeStyleAttributes[prop] &&
(!nativePropsToIgnore || !nativePropsToIgnore[prop])) {
throw new Error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ public void setBorderColor(ReactViewGroup view, int index, Integer color) {
color == null ? CSSConstants.UNDEFINED : (float) color);
}

@ReactProp(name = ViewProps.COLLAPSABLE)
public void setCollapsable(ReactViewGroup view, boolean collapsable) {
// no-op: it's here only so that "collapsable" property is exported to JS. The value is actually
// handled in NativeViewHierarchyOptimizer
}

@Override
public String getName() {
return REACT_CLASS;
Expand Down

0 comments on commit 7cd7591

Please sign in to comment.