From 95320626e111d092b7954f370d307df00ea3bb75 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Sun, 14 Jan 2018 19:32:31 -0800 Subject: [PATCH] Slight modernizing of Text.js to make it compatible with coming changes Reviewed By: sahrens Differential Revision: D6688488 fbshipit-source-id: da020b3510ac7163f63cb5cebc27ec4306b1136c --- Libraries/Text/Text.js | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 6268e59cc..0f8fe1a17 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -15,37 +15,20 @@ const ColorPropType = require('ColorPropType'); const EdgeInsetsPropType = require('EdgeInsetsPropType'); const NativeMethodsMixin = require('NativeMethodsMixin'); -const Platform = require('Platform'); const React = require('React'); const PropTypes = require('prop-types'); -const ReactNativeViewAttributes = require('ReactNativeViewAttributes'); const StyleSheetPropType = require('StyleSheetPropType'); const TextStylePropTypes = require('TextStylePropTypes'); const Touchable = require('Touchable'); +const UIManager = require('UIManager'); const createReactClass = require('create-react-class'); -const createReactNativeComponentClass = require('createReactNativeComponentClass'); +const requireNativeComponent = require('requireNativeComponent'); const mergeFast = require('mergeFast'); const processColor = require('processColor'); const stylePropType = StyleSheetPropType(TextStylePropTypes); -const viewConfig = { - validAttributes: mergeFast(ReactNativeViewAttributes.UIView, { - isHighlighted: true, - numberOfLines: true, - ellipsizeMode: true, - allowFontScaling: true, - disabled: true, - selectable: true, - selectionColor: true, - adjustsFontSizeToFit: true, - minimumFontScale: true, - textBreakStrategy: true, - }), - uiViewClassName: 'RCTText', -}; - /** * A React component for displaying text. * @@ -418,7 +401,6 @@ const Text = createReactClass({ }); }, mixins: [NativeMethodsMixin], - viewConfig: viewConfig, getChildContext(): Object { return {isInAParentText: true}; }, @@ -568,21 +550,11 @@ type RectOffset = { bottom: number, }; -var PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; +const PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; -var RCTText = createReactNativeComponentClass( - viewConfig.uiViewClassName, - () => viewConfig, -); -var RCTVirtualText = RCTText; - -if (Platform.OS === 'android') { - RCTVirtualText = createReactNativeComponentClass('RCTVirtualText', () => ({ - validAttributes: mergeFast(ReactNativeViewAttributes.UIView, { - isHighlighted: true, - }), - uiViewClassName: 'RCTVirtualText', - })); -} +const RCTText = requireNativeComponent('RCTText'); +const RCTVirtualText = UIManager.RCTVirtualText + ? requireNativeComponent('RCTVirtualText') + : RCTText; module.exports = Text;