Skip to content

Commit

Permalink
Removed exported constants for fixed-size views
Browse files Browse the repository at this point in the history
Summary: Creating a view instance just to get the default view size is quite expensive, and affects startup time for the bridge as it must be done on the main thread. I've removed these cases and simply hard-coded the sizes in the JS file. This will need to be updated if the view sizes ever change, but in practice that's very unlikely.

Reviewed By: javache

Differential Revision: D3218917

fb-gh-sync-id: 91a21dabb6046c5d4d5d0bec0845415cb3628ec3
fbshipit-source-id: 91a21dabb6046c5d4d5d0bec0845415cb3628ec3
  • Loading branch information
nicklockwood authored and Facebook Github Bot 9 committed Apr 26, 2016
1 parent 036199d commit c1aff6b
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 43 deletions.
5 changes: 2 additions & 3 deletions Libraries/Components/DatePicker/DatePickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
var NativeMethodsMixin = require('NativeMethodsMixin');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var RCTDatePickerIOSConsts = require('UIManager').RCTDatePicker.Constants;
var StyleSheet = require('StyleSheet');
var View = require('View');

Expand Down Expand Up @@ -142,8 +141,8 @@ var DatePickerIOS = React.createClass({

var styles = StyleSheet.create({
datePickerIOS: {
height: RCTDatePickerIOSConsts.ComponentHeight,
width: RCTDatePickerIOSConsts.ComponentWidth,
height: 216,
width: 320,
},
});

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
var NativeMethodsMixin = require('NativeMethodsMixin');
var React = require('React');
var ReactChildren = require('ReactChildren');
var RCTPickerIOSConsts = require('NativeModules').UIManager.RCTPicker.Constants;
var StyleSheet = require('StyleSheet');
var StyleSheetPropType = require('StyleSheetPropType');
var TextStylePropTypes = require('TextStylePropTypes');
Expand Down Expand Up @@ -108,7 +107,7 @@ var styles = StyleSheet.create({
// The picker will conform to whatever width is given, but we do
// have to set the component's height explicitly on the
// surrounding view to ensure it gets rendered.
height: RCTPickerIOSConsts.ComponentHeight,
height: 216,
},
});

Expand Down
3 changes: 1 addition & 2 deletions Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

var Image = require('Image');
var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var StyleSheet = require('StyleSheet');
Expand Down Expand Up @@ -72,7 +71,7 @@ var ProgressViewIOS = React.createClass({

var styles = StyleSheet.create({
progressView: {
height: NativeModules.ProgressViewManager.ComponentHeight
height: 2,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
'use strict';

var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var StyleSheet = require('StyleSheet');
Expand Down Expand Up @@ -120,7 +119,7 @@ var SegmentedControlIOS = React.createClass({

var styles = StyleSheet.create({
segmentedControl: {
height: NativeModules.SegmentedControlManager.ComponentHeight
height: 28,
},
});

Expand Down
9 changes: 0 additions & 9 deletions React/Views/RCTDatePickerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,4 @@ - (UIView *)view
RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode, UIDatePickerMode)
RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone, NSTimeZone)

- (NSDictionary<NSString *, id> *)constantsToExport
{
UIDatePicker *view = [UIDatePicker new];
return @{
@"ComponentHeight": @(view.intrinsicContentSize.height),
@"ComponentWidth": @(view.intrinsicContentSize.width),
};
}

@end
9 changes: 0 additions & 9 deletions React/Views/RCTPickerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,4 @@ - (UIView *)view
view.font = [RCTConvert UIFont:view.font withFamily:json ?: defaultView.font.familyName];
}

- (NSDictionary<NSString *, id> *)constantsToExport
{
UIPickerView *view = [UIPickerView new];
return @{
@"ComponentHeight": @(view.intrinsicContentSize.height),
@"ComponentWidth": @(view.intrinsicContentSize.width)
};
}

@end
8 changes: 0 additions & 8 deletions React/Views/RCTProgressViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,4 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(progressImage, UIImage)
RCT_EXPORT_VIEW_PROPERTY(trackImage, UIImage)

- (NSDictionary<NSString *, id> *)constantsToExport
{
UIProgressView *view = [UIProgressView new];
return @{
@"ComponentHeight": @(view.intrinsicContentSize.height),
};
}

@end
8 changes: 0 additions & 8 deletions React/Views/RCTSegmentedControlManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,4 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)

- (NSDictionary<NSString *, id> *)constantsToExport
{
RCTSegmentedControl *view = [RCTSegmentedControl new];
return @{
@"ComponentHeight": @(view.intrinsicContentSize.height),
};
}

@end

0 comments on commit c1aff6b

Please sign in to comment.