From 7c81d73532f4ca4566b70ad24a160a41806c198c Mon Sep 17 00:00:00 2001 From: Xiaosong Gao Date: Thu, 11 Jan 2018 18:36:27 +0800 Subject: [PATCH 1/6] To support react 16. --- src/Libraries/NavigationExperimental/NavigationPropTypes.js | 3 +-- src/api/CameraRoll.js | 3 +-- src/api/LayoutAnimation.js | 3 +-- src/components/ActivityIndicator.js | 6 +++--- src/components/ActivityIndicatorIOS.js | 6 +++--- src/components/DrawerLayoutAndroid.js | 3 ++- src/components/Image.js | 6 +++--- src/components/ListView.js | 6 +++--- src/components/Navigator.js | 3 ++- src/components/Picker.js | 3 ++- src/components/ScrollView.js | 6 +++--- src/components/StatusBar.js | 4 ++-- src/components/TabBarIOS.js | 3 ++- src/components/Text.js | 3 ++- src/components/TextInput.js | 6 +++--- src/components/TouchableNativeFeedback.js | 4 ++-- src/components/TouchableOpacity.js | 4 ++-- src/components/TouchableWithoutFeedback.js | 3 ++- src/components/View.js | 3 ++- src/components/WebView.js | 6 +++--- src/components/createMockComponent.js | 3 ++- src/plugins/requireNativeComponent.js | 3 ++- src/propTypes/EdgeInsetsPropType.js | 3 +-- src/propTypes/ImageStylePropTypes.js | 3 +-- src/propTypes/LayoutPropTypes.js | 3 +-- src/propTypes/PointPropType.js | 3 +-- src/propTypes/ShadowPropTypesIOS.js | 3 +-- src/propTypes/StyleSheetPropType.js | 3 +-- src/propTypes/TextStylePropTypes.js | 3 +-- src/propTypes/TransformPropTypes.js | 3 +-- src/propTypes/ViewPropTypes.js | 3 +-- src/propTypes/ViewStylePropTypes.js | 3 +-- 32 files changed, 58 insertions(+), 62 deletions(-) diff --git a/src/Libraries/NavigationExperimental/NavigationPropTypes.js b/src/Libraries/NavigationExperimental/NavigationPropTypes.js index 8caa73e..e13c0ae 100644 --- a/src/Libraries/NavigationExperimental/NavigationPropTypes.js +++ b/src/Libraries/NavigationExperimental/NavigationPropTypes.js @@ -1,8 +1,7 @@ class Animated {} import React from 'react'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; /* NavigationAction */ const action = PropTypes.shape({ diff --git a/src/api/CameraRoll.js b/src/api/CameraRoll.js index 02ab154..30cb375 100644 --- a/src/api/CameraRoll.js +++ b/src/api/CameraRoll.js @@ -1,8 +1,7 @@ import invariant from 'invariant'; import React from 'react'; import CameraRollManager from '../NativeModules/CameraRollManager'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; const GROUP_TYPES_OPTIONS = [ 'Album', diff --git a/src/api/LayoutAnimation.js b/src/api/LayoutAnimation.js index d5715ed..addc3dc 100644 --- a/src/api/LayoutAnimation.js +++ b/src/api/LayoutAnimation.js @@ -1,8 +1,7 @@ import React from 'react'; import UIManager from '../NativeModules/UIManager'; import keyMirror from 'keymirror'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; const TypesEnum = { spring: true, diff --git a/src/components/ActivityIndicator.js b/src/components/ActivityIndicator.js index 7d0f447..8fe9abd 100644 --- a/src/components/ActivityIndicator.js +++ b/src/components/ActivityIndicator.js @@ -5,10 +5,10 @@ import React from 'react'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import View from './View'; import ColorPropType from '../propTypes/ColorPropType'; +import PropTypes from 'prop-types'; +import createReactClass from 'create-react-class'; -const { PropTypes } = React; - -const ActivityIndicator = React.createClass({ +const ActivityIndicator = createReactClass({ propTypes: { ...View.propTypes, /** diff --git a/src/components/ActivityIndicatorIOS.js b/src/components/ActivityIndicatorIOS.js index 63a95ca..dd02125 100644 --- a/src/components/ActivityIndicatorIOS.js +++ b/src/components/ActivityIndicatorIOS.js @@ -4,10 +4,10 @@ import React from 'react'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import View from './View'; +import PropTypes from 'prop-types'; +import createReactClass from 'create-react-class'; -const { PropTypes } = React; - -const ActivityIndicatorIOS = React.createClass({ +const ActivityIndicatorIOS = createReactClass({ propTypes: { ...View.propTypes, /** diff --git a/src/components/DrawerLayoutAndroid.js b/src/components/DrawerLayoutAndroid.js index 86e1e37..61ac50b 100644 --- a/src/components/DrawerLayoutAndroid.js +++ b/src/components/DrawerLayoutAndroid.js @@ -6,11 +6,12 @@ import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import View from './View'; import UIManager from '../NativeModules/UIManager'; import ColorPropType from '../propTypes/ColorPropType'; +import createReactClass from 'create-react-class'; const ReactPropTypes = React.PropTypes; const DrawerConsts = UIManager.AndroidDrawerLayout.Constants; -const DrawerLayoutAndroid = React.createClass({ +const DrawerLayoutAndroid = createReactClass({ propTypes: { ...View.propTypes, diff --git a/src/components/Image.js b/src/components/Image.js index 3bc21fa..4c6c7d5 100644 --- a/src/components/Image.js +++ b/src/components/Image.js @@ -7,10 +7,10 @@ import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import EdgeInsetsPropType from '../propTypes/EdgeInsetsPropType'; import ImageStylePropTypes from '../propTypes/ImageStylePropTypes'; import ImageResizeMode from '../propTypes/ImageResizeMode'; +import PropTypes from 'prop-types'; +import createReactClass from 'create-react-class'; -const { PropTypes } = React; - -const Image = React.createClass({ +const Image = createReactClass({ propTypes: { style: styleSheetPropType(ImageStylePropTypes), /** diff --git a/src/components/ListView.js b/src/components/ListView.js index f546f45..ba72560 100644 --- a/src/components/ListView.js +++ b/src/components/ListView.js @@ -3,12 +3,12 @@ import ScrollResponder from '../mixins/ScrollResponder'; import TimerMixin from 'react-timer-mixin'; import ScrollView from './ScrollView'; import ListViewDataSource from '../api/ListViewDataSource'; +import PropTypes from 'prop-types'; +import createReactClass from 'create-react-class'; -const { PropTypes } = React; const SCROLLVIEW_REF = 'listviewscroll'; - -const ListView = React.createClass({ +const ListView = createReactClass({ propTypes: { ...ScrollView.propTypes, diff --git a/src/components/Navigator.js b/src/components/Navigator.js index 14a1d57..9bdab7b 100644 --- a/src/components/Navigator.js +++ b/src/components/Navigator.js @@ -1,6 +1,7 @@ import React, { PropTypes } from 'react'; import createMockComponent from './createMockComponent'; import View from './View'; +import createReactClass from 'create-react-class'; const NavigatorSceneConfigType = PropTypes.shape({ gestures: PropTypes.object, @@ -23,7 +24,7 @@ const NavigatorSceneConfigs = { VerticalDownSwipeJump: NavigatorSceneConfigType }; -const Navigator = React.createClass({ +const Navigator = createReactClass({ propTypes: { /** * Optional function that allows configuration about scene animations and diff --git a/src/components/Picker.js b/src/components/Picker.js index 97fc0eb..ce809d6 100644 --- a/src/components/Picker.js +++ b/src/components/Picker.js @@ -1,7 +1,8 @@ import React from 'react'; import createMockComponent from './createMockComponent'; +import createReactClass from 'create-react-class'; -const Picker = React.createClass({ +const Picker = createReactClass({ propTypes: { children: React.PropTypes.node }, diff --git a/src/components/ScrollView.js b/src/components/ScrollView.js index 2832369..1d125ec 100644 --- a/src/components/ScrollView.js +++ b/src/components/ScrollView.js @@ -6,13 +6,13 @@ import View from './View'; import ViewStylePropTypes from '../propTypes/ViewStylePropTypes'; import ScrollViewManager from '../NativeModules/ScrollViewManager'; import styleSheetPropType from '../propTypes/StyleSheetPropType'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; +import createReactClass from 'create-react-class'; const SCROLLVIEW = 'ScrollView'; const INNERVIEW = 'InnerScrollView'; -const ScrollView = React.createClass({ +const ScrollView = createReactClass({ propTypes: { ...View.propTypes, /** diff --git a/src/components/StatusBar.js b/src/components/StatusBar.js index f9f51f3..a2f557b 100644 --- a/src/components/StatusBar.js +++ b/src/components/StatusBar.js @@ -3,7 +3,7 @@ */ import React from 'react'; import ColorPropType from '../propTypes/ColorPropType'; - +import createReactClass from 'create-react-class'; let _backgroundColor = ''; let _barStyle = {}; @@ -11,7 +11,7 @@ let _hidden = false; let _networkActivityIndicatorVisible = false; let _translucent = false; -const StatusBar = React.createClass({ +const StatusBar = createReactClass({ propTypes: { animated: React.PropTypes.bool, barStyle: React.PropTypes.oneOf(['default', 'light-content']), diff --git a/src/components/TabBarIOS.js b/src/components/TabBarIOS.js index d474eee..95e3c44 100644 --- a/src/components/TabBarIOS.js +++ b/src/components/TabBarIOS.js @@ -1,7 +1,8 @@ import React from 'react'; import createMockComponent from './createMockComponent'; +import createReactClass from 'create-react-class'; -const TabBarIOS = React.createClass({ +const TabBarIOS = createReactClass({ propTypes: { children: React.PropTypes.node }, diff --git a/src/components/Text.js b/src/components/Text.js index a8a267b..8be16ad 100644 --- a/src/components/Text.js +++ b/src/components/Text.js @@ -5,10 +5,11 @@ import React from 'react'; import styleSheetPropType from '../propTypes/StyleSheetPropType'; import TextStylePropTypes from '../propTypes/TextStylePropTypes'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; +import createReactClass from 'create-react-class'; const stylePropType = styleSheetPropType(TextStylePropTypes); -const Text = React.createClass({ +const Text = createReactClass({ propTypes: { /** * Used to truncate the text with an ellipsis after computing the text diff --git a/src/components/TextInput.js b/src/components/TextInput.js index 5cec014..c18c318 100644 --- a/src/components/TextInput.js +++ b/src/components/TextInput.js @@ -4,10 +4,10 @@ import TimerMixin from 'react-timer-mixin'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import View from './View'; import Text from './Text'; +import PropTypes from 'prop-types'; +import createReactClass from 'create-react-class'; -const { PropTypes } = React; - -const TextInput = React.createClass({ +const TextInput = createReactClass({ propTypes: { ...View.propTypes, /** diff --git a/src/components/TouchableNativeFeedback.js b/src/components/TouchableNativeFeedback.js index bd606a5..335e4bc 100644 --- a/src/components/TouchableNativeFeedback.js +++ b/src/components/TouchableNativeFeedback.js @@ -1,9 +1,9 @@ import React from 'react'; - +import createReactClass from 'create-react-class'; import TouchableWithoutFeedback from './TouchableWithoutFeedback'; -const TouchableNativeFeedback = React.createClass({ +const TouchableNativeFeedback = createReactClass({ propTypes: { ...TouchableWithoutFeedback.propTypes, diff --git a/src/components/TouchableOpacity.js b/src/components/TouchableOpacity.js index aab17a8..fcbc3de 100644 --- a/src/components/TouchableOpacity.js +++ b/src/components/TouchableOpacity.js @@ -2,10 +2,10 @@ * https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/TouchableOpacity.js */ import React from 'react'; - +import createReactClass from 'create-react-class'; import TouchableWithoutFeedback from './TouchableWithoutFeedback'; -const TouchableOpacity = React.createClass({ +const TouchableOpacity = createReactClass({ propTypes: { ...TouchableWithoutFeedback.propTypes, diff --git a/src/components/TouchableWithoutFeedback.js b/src/components/TouchableWithoutFeedback.js index cf1d3e2..3363c63 100644 --- a/src/components/TouchableWithoutFeedback.js +++ b/src/components/TouchableWithoutFeedback.js @@ -4,8 +4,9 @@ import React from 'react'; import EdgeInsetsPropType from '../propTypes/EdgeInsetsPropType'; import View from './View'; +import createReactClass from 'create-react-class'; -const TouchableWithoutFeedback = React.createClass({ +const TouchableWithoutFeedback = createReactClass({ propTypes: { accessible: React.PropTypes.bool, accessibilityComponentType: React.PropTypes.oneOf(View.AccessibilityComponentType), diff --git a/src/components/View.js b/src/components/View.js index 75799d8..fc2fb0f 100644 --- a/src/components/View.js +++ b/src/components/View.js @@ -5,6 +5,7 @@ import React from 'react'; import ViewAccessibility from './ViewAccessibility'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import ViewPropTypes from '../propTypes/ViewPropTypes'; +import createReactClass from 'create-react-class'; const { AccessibilityTraits, AccessibilityComponentTypes } = ViewAccessibility; @@ -20,7 +21,7 @@ const statics = { forceTouchAvailable, }; -const View = React.createClass({ +const View = createReactClass({ propTypes: ViewPropTypes, mixins: [NativeMethodsMixin], diff --git a/src/components/WebView.js b/src/components/WebView.js index b4aac8b..772e2bc 100644 --- a/src/components/WebView.js +++ b/src/components/WebView.js @@ -3,8 +3,8 @@ import React from 'react'; import View from './View'; import ScrollView from './ScrollView'; import WebViewManager from '../NativeModules/WebViewManager'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; +import createReactClass from 'create-react-class'; const RCT_WEBVIEW_REF = 'webview'; @@ -19,7 +19,7 @@ const NavigationType = { const JSNavigationScheme = WebViewManager.JSNavigationScheme; -const WebView = React.createClass({ +const WebView = createReactClass({ propTypes: { ...View.propTypes, url: PropTypes.string, diff --git a/src/components/createMockComponent.js b/src/components/createMockComponent.js index f7b1a32..4b28841 100644 --- a/src/components/createMockComponent.js +++ b/src/components/createMockComponent.js @@ -1,7 +1,8 @@ import React from 'react'; +import createReactClass from 'create-react-class'; function createMockComponent(displayName) { - return React.createClass({ + return createReactClass({ displayName, render() { return null; diff --git a/src/plugins/requireNativeComponent.js b/src/plugins/requireNativeComponent.js index 6a35800..1732e13 100644 --- a/src/plugins/requireNativeComponent.js +++ b/src/plugins/requireNativeComponent.js @@ -2,9 +2,10 @@ * https://github.com/facebook/react-native/blob/master/Libraries/ReactIOS/requireNativeComponent.js */ import React from 'react'; +import createReactClass from 'create-react-class'; function requireNativeComponent(viewName, componentInterface, extraConfig) { - return React.createClass({ + return createReactClass({ displayName: viewName, render() { return null; diff --git a/src/propTypes/EdgeInsetsPropType.js b/src/propTypes/EdgeInsetsPropType.js index 14cd25a..6308d50 100644 --- a/src/propTypes/EdgeInsetsPropType.js +++ b/src/propTypes/EdgeInsetsPropType.js @@ -2,8 +2,7 @@ * https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/EdgeInsetsPropType.js */ import React from 'react'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; const EdgeInsetsPropType = PropTypes.shape({ top: PropTypes.number, diff --git a/src/propTypes/ImageStylePropTypes.js b/src/propTypes/ImageStylePropTypes.js index 2522dea..4be418c 100644 --- a/src/propTypes/ImageStylePropTypes.js +++ b/src/propTypes/ImageStylePropTypes.js @@ -7,8 +7,7 @@ import TransformPropTypes from './TransformPropTypes'; import ShadowPropTypesIOS from './ShadowPropTypesIOS'; import LayoutPropTypes from './LayoutPropTypes'; import ImageResizeMode from './ImageResizeMode'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; const ImageStylePropTypes = { ...LayoutPropTypes, diff --git a/src/propTypes/LayoutPropTypes.js b/src/propTypes/LayoutPropTypes.js index 020520f..401b364 100644 --- a/src/propTypes/LayoutPropTypes.js +++ b/src/propTypes/LayoutPropTypes.js @@ -2,8 +2,7 @@ * https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/LayoutPropTypes.js */ import React from 'react'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; /** * React Native's layout system is based on Flexbox and is powered both diff --git a/src/propTypes/PointPropType.js b/src/propTypes/PointPropType.js index e62e116..1434c34 100644 --- a/src/propTypes/PointPropType.js +++ b/src/propTypes/PointPropType.js @@ -2,8 +2,7 @@ * https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/PointPropType.js */ import React from 'react'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; const PointPropType = PropTypes.shape({ x: PropTypes.number, diff --git a/src/propTypes/ShadowPropTypesIOS.js b/src/propTypes/ShadowPropTypesIOS.js index 8899315..c4adf4c 100644 --- a/src/propTypes/ShadowPropTypesIOS.js +++ b/src/propTypes/ShadowPropTypesIOS.js @@ -1,7 +1,6 @@ import React from 'react'; import ColorPropType from './ColorPropType'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; const ShadowPropTypesIOS = { /** diff --git a/src/propTypes/StyleSheetPropType.js b/src/propTypes/StyleSheetPropType.js index c244660..9ca8d05 100644 --- a/src/propTypes/StyleSheetPropType.js +++ b/src/propTypes/StyleSheetPropType.js @@ -3,8 +3,7 @@ */ import React from 'react'; import flattenStyle from './flattenStyle'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; function StyleSheetPropType(shape) { const shapePropType = PropTypes.shape(shape); diff --git a/src/propTypes/TextStylePropTypes.js b/src/propTypes/TextStylePropTypes.js index 143f0cc..2e074e9 100644 --- a/src/propTypes/TextStylePropTypes.js +++ b/src/propTypes/TextStylePropTypes.js @@ -4,8 +4,7 @@ import React from 'react'; import ColorPropType from './ColorPropType'; import ViewStylePropTypes from './ViewStylePropTypes'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; // TODO: use spread instead of Object.assign/create after #6560135 is fixed const TextStylePropTypes = Object.assign(Object.create(ViewStylePropTypes), { diff --git a/src/propTypes/TransformPropTypes.js b/src/propTypes/TransformPropTypes.js index b49bfe8..0114358 100644 --- a/src/propTypes/TransformPropTypes.js +++ b/src/propTypes/TransformPropTypes.js @@ -2,8 +2,7 @@ * https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/TransformPropTypes.js */ import React from 'react'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; const arrayOfNumberPropType = PropTypes.arrayOf(PropTypes.number); diff --git a/src/propTypes/ViewPropTypes.js b/src/propTypes/ViewPropTypes.js index 673c0ab..899aba5 100644 --- a/src/propTypes/ViewPropTypes.js +++ b/src/propTypes/ViewPropTypes.js @@ -7,11 +7,10 @@ import EdgeInsetsPropType from './EdgeInsetsPropType'; import styleSheetPropType from './StyleSheetPropType'; import ViewStylePropTypes from './ViewStylePropTypes'; import { AccessibilityComponentTypes, AccessibilityTraits } from '../components/ViewAccessibility'; +import PropTypes from 'prop-types'; const stylePropType = styleSheetPropType(ViewStylePropTypes); -const { PropTypes } = React; - const ViewPropTypes = { /** * When `true`, indicates that the view is an accessibility element. By default, diff --git a/src/propTypes/ViewStylePropTypes.js b/src/propTypes/ViewStylePropTypes.js index b8e168a..c1db7d7 100644 --- a/src/propTypes/ViewStylePropTypes.js +++ b/src/propTypes/ViewStylePropTypes.js @@ -6,8 +6,7 @@ import ColorPropType from './ColorPropType'; import LayoutPropTypes from './LayoutPropTypes'; import ShadowPropTypesIOS from './ShadowPropTypesIOS'; import TransformPropTypes from './TransformPropTypes'; - -const { PropTypes } = React; +import PropTypes from 'prop-types'; /** * Warning: Some of these properties may not be supported in all releases. From 2f8547a05514f48f1824c781bac7e54c08c5f09d Mon Sep 17 00:00:00 2001 From: Xiaosong Gao Date: Thu, 11 Jan 2018 19:24:24 +0800 Subject: [PATCH 2/6] Remove PropTypes, React.createClass and react-addons-test-utils. --- package.json | 1 - src/components/Navigator.js | 3 ++- src/react-native.js | 2 +- test/components/DrawerLayoutAndroid.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 08eb627..e1d6862 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "react-addons-create-fragment": "^15.4.0", "react-addons-perf": "^15.4.0", "react-addons-pure-render-mixin": "^15.4.0", - "react-addons-test-utils": "^15.4.0", "react-addons-update": "^15.4.0", "react-dom": "^15.4.0", "react-timer-mixin": "^0.13.3", diff --git a/src/components/Navigator.js b/src/components/Navigator.js index 9bdab7b..8b76d52 100644 --- a/src/components/Navigator.js +++ b/src/components/Navigator.js @@ -1,6 +1,7 @@ -import React, { PropTypes } from 'react'; +import React from 'react'; import createMockComponent from './createMockComponent'; import View from './View'; +import PropTypes from 'prop-types'; import createReactClass from 'create-react-class'; const NavigatorSceneConfigType = PropTypes.shape({ diff --git a/src/react-native.js b/src/react-native.js index 2ca8d22..2471e62 100644 --- a/src/react-native.js +++ b/src/react-native.js @@ -111,7 +111,7 @@ const ReactNativeAddons = { Perf: require('react-addons-perf'), PureRenderMixin: require('react-addons-pure-render-mixin'), TestModule: require('./NativeModules/TestModule'), - TestUtils: require('react-addons-test-utils'), + TestUtils: require('react-dom/test-utils'), // TODO(lmr): not sure where to find this // batchedUpdates: require('ReactUpdates').batchedUpdates, deprecated // cloneWithProps: require('react-addons-clone-with-props'), deprecated diff --git a/test/components/DrawerLayoutAndroid.js b/test/components/DrawerLayoutAndroid.js index 5e1af92..8020db5 100644 --- a/test/components/DrawerLayoutAndroid.js +++ b/test/components/DrawerLayoutAndroid.js @@ -2,7 +2,7 @@ import React from 'react'; import { DrawerLayoutAndroid } from '../../src/react-native'; import { expect } from 'chai'; -import ReactTestUtils from 'react-addons-test-utils'; +import ReactTestUtils from 'react-dom/test-utils'; describe('DrawerLayoutAndroid', () => { it('should render an empty DrawerLayoutAndroid', () => { From 5bfc74d481fe7b685140b09047aa8c20c3309018 Mon Sep 17 00:00:00 2001 From: Xiaosong Gao Date: Thu, 11 Jan 2018 19:30:36 +0800 Subject: [PATCH 3/6] Update React version. --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index e1d6862..2b31367 100644 --- a/package.json +++ b/package.json @@ -41,19 +41,19 @@ "eslint-plugin-react": "5.1.1", "eslint-plugin-react-native": "1.0.2", "mocha": "2.5.3", - "react": "^15.4.0", - "react-native": "^0.38.0" + "react": "^16.0.0", + "react-native": "^0.50.0" }, "dependencies": { "cubic-bezier": "^0.1.2", "invariant": "^2.2.1", "keymirror": "^0.1.1", "raf": "^3.2.0", - "react-addons-create-fragment": "^15.4.0", - "react-addons-perf": "^15.4.0", - "react-addons-pure-render-mixin": "^15.4.0", - "react-addons-update": "^15.4.0", - "react-dom": "^15.4.0", + "react-addons-create-fragment": "^16.0.0-alpha.3", + "react-addons-perf": "^16.0.0-alpha.3", + "react-addons-pure-render-mixin": "^16.0.0-alpha.3", + "react-addons-update": "^16.0.0-alpha.3", + "react-dom": "^16.0.0", "react-timer-mixin": "^0.13.3", "warning": "^2.1.0" }, From 485df149686534c543deb8c78da1f38412765165 Mon Sep 17 00:00:00 2001 From: Xiaosong Gao Date: Thu, 11 Jan 2018 19:46:17 +0800 Subject: [PATCH 4/6] Remove React.PropTypes. --- src/components/DrawerLayoutAndroid.js | 2 +- src/components/ListView.js | 8 +++--- src/components/Navigator.js | 2 +- src/components/Picker.js | 3 ++- src/components/StatusBar.js | 13 +++++----- src/components/TabBarIOS.js | 3 ++- src/components/Text.js | 13 +++++----- src/components/TouchableNativeFeedback.js | 3 ++- src/components/TouchableOpacity.js | 3 ++- src/components/TouchableWithoutFeedback.js | 29 +++++++++++----------- 10 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/components/DrawerLayoutAndroid.js b/src/components/DrawerLayoutAndroid.js index 61ac50b..7b40856 100644 --- a/src/components/DrawerLayoutAndroid.js +++ b/src/components/DrawerLayoutAndroid.js @@ -8,7 +8,7 @@ import UIManager from '../NativeModules/UIManager'; import ColorPropType from '../propTypes/ColorPropType'; import createReactClass from 'create-react-class'; -const ReactPropTypes = React.PropTypes; +const ReactPropTypes = require('prop-types'); const DrawerConsts = UIManager.AndroidDrawerLayout.Constants; const DrawerLayoutAndroid = createReactClass({ diff --git a/src/components/ListView.js b/src/components/ListView.js index ba72560..13fcdf0 100644 --- a/src/components/ListView.js +++ b/src/components/ListView.js @@ -80,12 +80,12 @@ const ListView = createReactClass({ * A function that returns the scrollable component in which the list rows * are rendered. Defaults to returning a ScrollView with the given props. */ - renderScrollComponent: React.PropTypes.func.isRequired, + renderScrollComponent: PropTypes.func.isRequired, /** * How early to start rendering rows before they come on screen, in * pixels. */ - scrollRenderAheadDistance: React.PropTypes.number, + scrollRenderAheadDistance: PropTypes.number, /** * (visibleRows, changedRows) => void * @@ -95,13 +95,13 @@ const ListView = createReactClass({ * that have changed their visibility, with true indicating visible, and * false indicating the view has moved out of view. */ - onChangeVisibleRows: React.PropTypes.func, + onChangeVisibleRows: PropTypes.func, /** * A performance optimization for improving scroll perf of * large lists, used in conjunction with overflow: 'hidden' on the row * containers. This is enabled by default. */ - removeClippedSubviews: React.PropTypes.bool, + removeClippedSubviews: PropTypes.bool, /** * An array of child indices determining which children get docked to the * top of the screen when scrolling. For example, passing diff --git a/src/components/Navigator.js b/src/components/Navigator.js index 8b76d52..6138423 100644 --- a/src/components/Navigator.js +++ b/src/components/Navigator.js @@ -9,7 +9,7 @@ const NavigatorSceneConfigType = PropTypes.shape({ springFriction: PropTypes.number, springTension: PropTypes.number, defaultTransitionVelocity: PropTypes.number, - animationInterpolators: React.PropTypes.object, + animationInterpolators: PropTypes.object, }); const NavigatorSceneConfigs = { diff --git a/src/components/Picker.js b/src/components/Picker.js index ce809d6..0460cfe 100644 --- a/src/components/Picker.js +++ b/src/components/Picker.js @@ -1,10 +1,11 @@ import React from 'react'; import createMockComponent from './createMockComponent'; import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; const Picker = createReactClass({ propTypes: { - children: React.PropTypes.node + children: PropTypes.node }, statics: { Item: createMockComponent('Picker.Item') diff --git a/src/components/StatusBar.js b/src/components/StatusBar.js index a2f557b..75fdbcc 100644 --- a/src/components/StatusBar.js +++ b/src/components/StatusBar.js @@ -4,6 +4,7 @@ import React from 'react'; import ColorPropType from '../propTypes/ColorPropType'; import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; let _backgroundColor = ''; let _barStyle = {}; @@ -13,13 +14,13 @@ let _translucent = false; const StatusBar = createReactClass({ propTypes: { - animated: React.PropTypes.bool, - barStyle: React.PropTypes.oneOf(['default', 'light-content']), + animated: PropTypes.bool, + barStyle: PropTypes.oneOf(['default', 'light-content']), backgroundColor: ColorPropType, - hidden: React.PropTypes.bool, - networkActivityIndicatorVisible: React.PropTypes.bool, - showHideTransition: React.PropTypes.oneOf(['fade', 'slide']), - translucent: React.PropTypes.bool + hidden: PropTypes.bool, + networkActivityIndicatorVisible: PropTypes.bool, + showHideTransition: PropTypes.oneOf(['fade', 'slide']), + translucent: PropTypes.bool }, statics: { diff --git a/src/components/TabBarIOS.js b/src/components/TabBarIOS.js index 95e3c44..5dcdb39 100644 --- a/src/components/TabBarIOS.js +++ b/src/components/TabBarIOS.js @@ -1,10 +1,11 @@ import React from 'react'; import createMockComponent from './createMockComponent'; import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; const TabBarIOS = createReactClass({ propTypes: { - children: React.PropTypes.node + children: PropTypes.node }, statics: { Item: createMockComponent('TabBarIOS.Item') diff --git a/src/components/Text.js b/src/components/Text.js index 8be16ad..9d94f88 100644 --- a/src/components/Text.js +++ b/src/components/Text.js @@ -6,6 +6,7 @@ import styleSheetPropType from '../propTypes/StyleSheetPropType'; import TextStylePropTypes from '../propTypes/TextStylePropTypes'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; const stylePropType = styleSheetPropType(TextStylePropTypes); @@ -16,33 +17,33 @@ const Text = createReactClass({ * layout, including line wrapping, such that the total number of lines * does not exceed this number. */ - numberOfLines: React.PropTypes.number, + numberOfLines: PropTypes.number, /** * Invoked on mount and layout changes with * * `{nativeEvent: {layout: {x, y, width, height}}}` */ - onLayout: React.PropTypes.func, + onLayout: PropTypes.func, /** * This function is called on press. */ - onPress: React.PropTypes.func, + onPress: PropTypes.func, /** * When true, no visual change is made when text is pressed down. By * default, a gray oval highlights the text on press down. * @platform ios */ - suppressHighlighting: React.PropTypes.bool, + suppressHighlighting: PropTypes.bool, style: stylePropType, /** * Used to locate this view in end-to-end tests. */ - testID: React.PropTypes.string, + testID: PropTypes.string, /** * Specifies should fonts scale to respect Text Size accessibility setting on iOS. * @platform ios */ - allowFontScaling: React.PropTypes.bool, + allowFontScaling: PropTypes.bool, }, mixins: [NativeMethodsMixin], diff --git a/src/components/TouchableNativeFeedback.js b/src/components/TouchableNativeFeedback.js index 335e4bc..d189716 100644 --- a/src/components/TouchableNativeFeedback.js +++ b/src/components/TouchableNativeFeedback.js @@ -2,12 +2,13 @@ import React from 'react'; import createReactClass from 'create-react-class'; import TouchableWithoutFeedback from './TouchableWithoutFeedback'; +import PropTypes from 'prop-types'; const TouchableNativeFeedback = createReactClass({ propTypes: { ...TouchableWithoutFeedback.propTypes, - background: React.PropTypes.object + background: PropTypes.object }, statics: { SelectableBackground() {}, diff --git a/src/components/TouchableOpacity.js b/src/components/TouchableOpacity.js index fcbc3de..432d053 100644 --- a/src/components/TouchableOpacity.js +++ b/src/components/TouchableOpacity.js @@ -4,6 +4,7 @@ import React from 'react'; import createReactClass from 'create-react-class'; import TouchableWithoutFeedback from './TouchableWithoutFeedback'; +import PropTypes from 'prop-types'; const TouchableOpacity = createReactClass({ propTypes: { @@ -13,7 +14,7 @@ const TouchableOpacity = createReactClass({ * Determines what the opacity of the wrapped view should be when touch is * active. Defaults to 0.2. */ - activeOpacity: React.PropTypes.number, + activeOpacity: PropTypes.number, }, render() { diff --git a/src/components/TouchableWithoutFeedback.js b/src/components/TouchableWithoutFeedback.js index 3363c63..b97d805 100644 --- a/src/components/TouchableWithoutFeedback.js +++ b/src/components/TouchableWithoutFeedback.js @@ -5,47 +5,48 @@ import React from 'react'; import EdgeInsetsPropType from '../propTypes/EdgeInsetsPropType'; import View from './View'; import createReactClass from 'create-react-class'; +import PropTypes from 'prop-types'; const TouchableWithoutFeedback = createReactClass({ propTypes: { - accessible: React.PropTypes.bool, - accessibilityComponentType: React.PropTypes.oneOf(View.AccessibilityComponentType), - accessibilityTraits: React.PropTypes.oneOfType([ - React.PropTypes.oneOf(View.AccessibilityTraits), - React.PropTypes.arrayOf(React.PropTypes.oneOf(View.AccessibilityTraits)), + accessible: PropTypes.bool, + accessibilityComponentType: PropTypes.oneOf(View.AccessibilityComponentType), + accessibilityTraits: PropTypes.oneOfType([ + PropTypes.oneOf(View.AccessibilityTraits), + PropTypes.arrayOf(PropTypes.oneOf(View.AccessibilityTraits)), ]), /** * If true, disable all interactions for this component. */ - disabled: React.PropTypes.bool, + disabled: PropTypes.bool, /** * Called when the touch is released, but not if cancelled (e.g. by a scroll * that steals the responder lock). */ - onPress: React.PropTypes.func, - onPressIn: React.PropTypes.func, - onPressOut: React.PropTypes.func, + onPress: PropTypes.func, + onPressIn: PropTypes.func, + onPressOut: PropTypes.func, /** * Invoked on mount and layout changes with * * `{nativeEvent: {layout: {x, y, width, height}}}` */ - onLayout: React.PropTypes.func, + onLayout: PropTypes.func, - onLongPress: React.PropTypes.func, + onLongPress: PropTypes.func, /** * Delay in ms, from the start of the touch, before onPressIn is called. */ - delayPressIn: React.PropTypes.number, + delayPressIn: PropTypes.number, /** * Delay in ms, from the release of the touch, before onPressOut is called. */ - delayPressOut: React.PropTypes.number, + delayPressOut: PropTypes.number, /** * Delay in ms, from onPressIn, before onLongPress is called. */ - delayLongPress: React.PropTypes.number, + delayLongPress: PropTypes.number, /** * When the scroll view is disabled, this defines how far your touch may * move off of the button, before deactivating the button. Once deactivated, From 8952fb4061b1297769f107b0ce39b6443fb90ac5 Mon Sep 17 00:00:00 2001 From: Xiaosong Gao Date: Thu, 11 Jan 2018 20:07:39 +0800 Subject: [PATCH 5/6] Replace some addons. --- package.json | 5 +---- src/react-native.js | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 2b31367..715170a 100644 --- a/package.json +++ b/package.json @@ -46,13 +46,10 @@ }, "dependencies": { "cubic-bezier": "^0.1.2", + "immutability-helper": "^2.6.4", "invariant": "^2.2.1", "keymirror": "^0.1.1", "raf": "^3.2.0", - "react-addons-create-fragment": "^16.0.0-alpha.3", - "react-addons-perf": "^16.0.0-alpha.3", - "react-addons-pure-render-mixin": "^16.0.0-alpha.3", - "react-addons-update": "^16.0.0-alpha.3", "react-dom": "^16.0.0", "react-timer-mixin": "^0.13.3", "warning": "^2.1.0" diff --git a/src/react-native.js b/src/react-native.js index 2471e62..413037c 100644 --- a/src/react-native.js +++ b/src/react-native.js @@ -108,15 +108,15 @@ const ReactNative = { // See http://facebook.github.io/react/docs/addons.html const ReactNativeAddons = { // LinkedStateMixin: require('react-addons-linked-state-mixin') deprecated, - Perf: require('react-addons-perf'), - PureRenderMixin: require('react-addons-pure-render-mixin'), + // Perf: require('react-addons-perf'), + // PureRenderMixin: require('react-addons-pure-render-mixin'), TestModule: require('./NativeModules/TestModule'), TestUtils: require('react-dom/test-utils'), // TODO(lmr): not sure where to find this // batchedUpdates: require('ReactUpdates').batchedUpdates, deprecated // cloneWithProps: require('react-addons-clone-with-props'), deprecated - createFragment: require('react-addons-create-fragment'), - update: require('react-addons-update'), + // createFragment: require('react-addons-create-fragment'), + update: require('immutability-helper'), }; Object.assign(ReactNative, React, { addons: ReactNativeAddons }); From af728964e21daac2d77a1162d2c6cb077350c187 Mon Sep 17 00:00:00 2001 From: Xiaosong Gao Date: Thu, 11 Jan 2018 20:34:03 +0800 Subject: [PATCH 6/6] Remove unused code and pass test case. --- package.json | 1 + src/Libraries/NavigationExperimental/NavigationPropTypes.js | 1 - src/api/CameraRoll.js | 1 - src/api/LayoutAnimation.js | 1 - src/components/ActivityIndicator.js | 1 - src/components/ActivityIndicatorIOS.js | 1 - src/components/DrawerLayoutAndroid.js | 1 - src/components/Image.js | 1 - src/components/Navigator.js | 1 - src/components/Picker.js | 1 - src/components/StatusBar.js | 1 - src/components/TabBarIOS.js | 1 - src/components/Text.js | 1 - src/components/TouchableNativeFeedback.js | 2 -- src/components/TouchableOpacity.js | 1 - src/components/TouchableWithoutFeedback.js | 1 - src/components/View.js | 1 - src/components/createMockComponent.js | 1 - src/plugins/requireNativeComponent.js | 1 - src/propTypes/EdgeInsetsPropType.js | 1 - src/propTypes/ImageStylePropTypes.js | 1 - src/propTypes/LayoutPropTypes.js | 1 - src/propTypes/PointPropType.js | 1 - src/propTypes/ShadowPropTypesIOS.js | 1 - src/propTypes/StyleSheetPropType.js | 1 - src/propTypes/TextStylePropTypes.js | 1 - src/propTypes/TransformPropTypes.js | 1 - src/propTypes/ViewPropTypes.js | 2 -- src/propTypes/ViewStylePropTypes.js | 1 - src/react-native.js | 2 +- test/components/DrawerLayoutAndroid.js | 6 +++--- 31 files changed, 5 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 715170a..33a81fe 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "keymirror": "^0.1.1", "raf": "^3.2.0", "react-dom": "^16.0.0", + "react-test-renderer": "^16.2.0", "react-timer-mixin": "^0.13.3", "warning": "^2.1.0" }, diff --git a/src/Libraries/NavigationExperimental/NavigationPropTypes.js b/src/Libraries/NavigationExperimental/NavigationPropTypes.js index e13c0ae..114e59c 100644 --- a/src/Libraries/NavigationExperimental/NavigationPropTypes.js +++ b/src/Libraries/NavigationExperimental/NavigationPropTypes.js @@ -1,6 +1,5 @@ class Animated {} -import React from 'react'; import PropTypes from 'prop-types'; /* NavigationAction */ diff --git a/src/api/CameraRoll.js b/src/api/CameraRoll.js index 30cb375..0f8aadf 100644 --- a/src/api/CameraRoll.js +++ b/src/api/CameraRoll.js @@ -1,5 +1,4 @@ import invariant from 'invariant'; -import React from 'react'; import CameraRollManager from '../NativeModules/CameraRollManager'; import PropTypes from 'prop-types'; diff --git a/src/api/LayoutAnimation.js b/src/api/LayoutAnimation.js index addc3dc..15ebe34 100644 --- a/src/api/LayoutAnimation.js +++ b/src/api/LayoutAnimation.js @@ -1,4 +1,3 @@ -import React from 'react'; import UIManager from '../NativeModules/UIManager'; import keyMirror from 'keymirror'; import PropTypes from 'prop-types'; diff --git a/src/components/ActivityIndicator.js b/src/components/ActivityIndicator.js index 8fe9abd..47e806d 100644 --- a/src/components/ActivityIndicator.js +++ b/src/components/ActivityIndicator.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Components/ActivityIndicator/ActivityIndicator.js */ -import React from 'react'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import View from './View'; import ColorPropType from '../propTypes/ColorPropType'; diff --git a/src/components/ActivityIndicatorIOS.js b/src/components/ActivityIndicatorIOS.js index dd02125..d72c9ff 100644 --- a/src/components/ActivityIndicatorIOS.js +++ b/src/components/ActivityIndicatorIOS.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.ios.js */ -import React from 'react'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import View from './View'; import PropTypes from 'prop-types'; diff --git a/src/components/DrawerLayoutAndroid.js b/src/components/DrawerLayoutAndroid.js index 7b40856..9d3dff6 100644 --- a/src/components/DrawerLayoutAndroid.js +++ b/src/components/DrawerLayoutAndroid.js @@ -1,7 +1,6 @@ /** *https://github.com/facebook/react-native/blob/master/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js */ -import React from 'react'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import View from './View'; import UIManager from '../NativeModules/UIManager'; diff --git a/src/components/Image.js b/src/components/Image.js index 4c6c7d5..fb59acd 100644 --- a/src/components/Image.js +++ b/src/components/Image.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Image/Image.ios.js */ -import React from 'react'; import styleSheetPropType from '../propTypes/StyleSheetPropType'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import EdgeInsetsPropType from '../propTypes/EdgeInsetsPropType'; diff --git a/src/components/Navigator.js b/src/components/Navigator.js index 6138423..ccfc15c 100644 --- a/src/components/Navigator.js +++ b/src/components/Navigator.js @@ -1,4 +1,3 @@ -import React from 'react'; import createMockComponent from './createMockComponent'; import View from './View'; import PropTypes from 'prop-types'; diff --git a/src/components/Picker.js b/src/components/Picker.js index 0460cfe..7fe07ee 100644 --- a/src/components/Picker.js +++ b/src/components/Picker.js @@ -1,4 +1,3 @@ -import React from 'react'; import createMockComponent from './createMockComponent'; import createReactClass from 'create-react-class'; import PropTypes from 'prop-types'; diff --git a/src/components/StatusBar.js b/src/components/StatusBar.js index 75fdbcc..c2d566f 100644 --- a/src/components/StatusBar.js +++ b/src/components/StatusBar.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Components/StatusBar/StatusBar.js */ -import React from 'react'; import ColorPropType from '../propTypes/ColorPropType'; import createReactClass from 'create-react-class'; import PropTypes from 'prop-types'; diff --git a/src/components/TabBarIOS.js b/src/components/TabBarIOS.js index 5dcdb39..3688353 100644 --- a/src/components/TabBarIOS.js +++ b/src/components/TabBarIOS.js @@ -1,4 +1,3 @@ -import React from 'react'; import createMockComponent from './createMockComponent'; import createReactClass from 'create-react-class'; import PropTypes from 'prop-types'; diff --git a/src/components/Text.js b/src/components/Text.js index 9d94f88..c80e09d 100644 --- a/src/components/Text.js +++ b/src/components/Text.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Text/Text.js */ -import React from 'react'; import styleSheetPropType from '../propTypes/StyleSheetPropType'; import TextStylePropTypes from '../propTypes/TextStylePropTypes'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; diff --git a/src/components/TouchableNativeFeedback.js b/src/components/TouchableNativeFeedback.js index d189716..cb8cc28 100644 --- a/src/components/TouchableNativeFeedback.js +++ b/src/components/TouchableNativeFeedback.js @@ -1,5 +1,3 @@ - -import React from 'react'; import createReactClass from 'create-react-class'; import TouchableWithoutFeedback from './TouchableWithoutFeedback'; import PropTypes from 'prop-types'; diff --git a/src/components/TouchableOpacity.js b/src/components/TouchableOpacity.js index 432d053..6c3b35e 100644 --- a/src/components/TouchableOpacity.js +++ b/src/components/TouchableOpacity.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/TouchableOpacity.js */ -import React from 'react'; import createReactClass from 'create-react-class'; import TouchableWithoutFeedback from './TouchableWithoutFeedback'; import PropTypes from 'prop-types'; diff --git a/src/components/TouchableWithoutFeedback.js b/src/components/TouchableWithoutFeedback.js index b97d805..14513cd 100644 --- a/src/components/TouchableWithoutFeedback.js +++ b/src/components/TouchableWithoutFeedback.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/TouchableWithoutFeedback.js */ -import React from 'react'; import EdgeInsetsPropType from '../propTypes/EdgeInsetsPropType'; import View from './View'; import createReactClass from 'create-react-class'; diff --git a/src/components/View.js b/src/components/View.js index fc2fb0f..301b61f 100644 --- a/src/components/View.js +++ b/src/components/View.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Components/View/View.js */ -import React from 'react'; import ViewAccessibility from './ViewAccessibility'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import ViewPropTypes from '../propTypes/ViewPropTypes'; diff --git a/src/components/createMockComponent.js b/src/components/createMockComponent.js index 4b28841..546ab6a 100644 --- a/src/components/createMockComponent.js +++ b/src/components/createMockComponent.js @@ -1,4 +1,3 @@ -import React from 'react'; import createReactClass from 'create-react-class'; function createMockComponent(displayName) { diff --git a/src/plugins/requireNativeComponent.js b/src/plugins/requireNativeComponent.js index 1732e13..a261fa0 100644 --- a/src/plugins/requireNativeComponent.js +++ b/src/plugins/requireNativeComponent.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/ReactIOS/requireNativeComponent.js */ -import React from 'react'; import createReactClass from 'create-react-class'; function requireNativeComponent(viewName, componentInterface, extraConfig) { diff --git a/src/propTypes/EdgeInsetsPropType.js b/src/propTypes/EdgeInsetsPropType.js index 6308d50..ec68321 100644 --- a/src/propTypes/EdgeInsetsPropType.js +++ b/src/propTypes/EdgeInsetsPropType.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/EdgeInsetsPropType.js */ -import React from 'react'; import PropTypes from 'prop-types'; const EdgeInsetsPropType = PropTypes.shape({ diff --git a/src/propTypes/ImageStylePropTypes.js b/src/propTypes/ImageStylePropTypes.js index 4be418c..ee42d9c 100644 --- a/src/propTypes/ImageStylePropTypes.js +++ b/src/propTypes/ImageStylePropTypes.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Image/ImageStylePropTypes.js */ -import React from 'react'; import ColorPropType from './ColorPropType'; import TransformPropTypes from './TransformPropTypes'; import ShadowPropTypesIOS from './ShadowPropTypesIOS'; diff --git a/src/propTypes/LayoutPropTypes.js b/src/propTypes/LayoutPropTypes.js index 401b364..c2b5d75 100644 --- a/src/propTypes/LayoutPropTypes.js +++ b/src/propTypes/LayoutPropTypes.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/LayoutPropTypes.js */ -import React from 'react'; import PropTypes from 'prop-types'; /** diff --git a/src/propTypes/PointPropType.js b/src/propTypes/PointPropType.js index 1434c34..6879694 100644 --- a/src/propTypes/PointPropType.js +++ b/src/propTypes/PointPropType.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/PointPropType.js */ -import React from 'react'; import PropTypes from 'prop-types'; const PointPropType = PropTypes.shape({ diff --git a/src/propTypes/ShadowPropTypesIOS.js b/src/propTypes/ShadowPropTypesIOS.js index c4adf4c..e22c222 100644 --- a/src/propTypes/ShadowPropTypesIOS.js +++ b/src/propTypes/ShadowPropTypesIOS.js @@ -1,4 +1,3 @@ -import React from 'react'; import ColorPropType from './ColorPropType'; import PropTypes from 'prop-types'; diff --git a/src/propTypes/StyleSheetPropType.js b/src/propTypes/StyleSheetPropType.js index 9ca8d05..bd14bbc 100644 --- a/src/propTypes/StyleSheetPropType.js +++ b/src/propTypes/StyleSheetPropType.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/StyleSheetPropType.js */ -import React from 'react'; import flattenStyle from './flattenStyle'; import PropTypes from 'prop-types'; diff --git a/src/propTypes/TextStylePropTypes.js b/src/propTypes/TextStylePropTypes.js index 2e074e9..b7aa32c 100644 --- a/src/propTypes/TextStylePropTypes.js +++ b/src/propTypes/TextStylePropTypes.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Text/TextStylePropTypes.js */ -import React from 'react'; import ColorPropType from './ColorPropType'; import ViewStylePropTypes from './ViewStylePropTypes'; import PropTypes from 'prop-types'; diff --git a/src/propTypes/TransformPropTypes.js b/src/propTypes/TransformPropTypes.js index 0114358..1096460 100644 --- a/src/propTypes/TransformPropTypes.js +++ b/src/propTypes/TransformPropTypes.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/TransformPropTypes.js */ -import React from 'react'; import PropTypes from 'prop-types'; const arrayOfNumberPropType = PropTypes.arrayOf(PropTypes.number); diff --git a/src/propTypes/ViewPropTypes.js b/src/propTypes/ViewPropTypes.js index 899aba5..f754962 100644 --- a/src/propTypes/ViewPropTypes.js +++ b/src/propTypes/ViewPropTypes.js @@ -1,8 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Components/View/ViewPropTypes.js */ - -import React from 'react'; import EdgeInsetsPropType from './EdgeInsetsPropType'; import styleSheetPropType from './StyleSheetPropType'; import ViewStylePropTypes from './ViewStylePropTypes'; diff --git a/src/propTypes/ViewStylePropTypes.js b/src/propTypes/ViewStylePropTypes.js index c1db7d7..36d40f3 100644 --- a/src/propTypes/ViewStylePropTypes.js +++ b/src/propTypes/ViewStylePropTypes.js @@ -1,7 +1,6 @@ /** * https://github.com/facebook/react-native/blob/master/Libraries/Components/View/ViewStylePropTypes.js */ -import React from 'react'; import ColorPropType from './ColorPropType'; import LayoutPropTypes from './LayoutPropTypes'; import ShadowPropTypesIOS from './ShadowPropTypesIOS'; diff --git a/src/react-native.js b/src/react-native.js index 413037c..e4d7242 100644 --- a/src/react-native.js +++ b/src/react-native.js @@ -111,7 +111,7 @@ const ReactNativeAddons = { // Perf: require('react-addons-perf'), // PureRenderMixin: require('react-addons-pure-render-mixin'), TestModule: require('./NativeModules/TestModule'), - TestUtils: require('react-dom/test-utils'), + TestUtils: require('react-test-renderer/shallow'), // TODO(lmr): not sure where to find this // batchedUpdates: require('ReactUpdates').batchedUpdates, deprecated // cloneWithProps: require('react-addons-clone-with-props'), deprecated diff --git a/test/components/DrawerLayoutAndroid.js b/test/components/DrawerLayoutAndroid.js index 8020db5..2c01275 100644 --- a/test/components/DrawerLayoutAndroid.js +++ b/test/components/DrawerLayoutAndroid.js @@ -2,12 +2,12 @@ import React from 'react'; import { DrawerLayoutAndroid } from '../../src/react-native'; import { expect } from 'chai'; -import ReactTestUtils from 'react-dom/test-utils'; +import ShallowRenderer from 'react-test-renderer/shallow'; describe('DrawerLayoutAndroid', () => { it('should render an empty DrawerLayoutAndroid', () => { - const renderer = ReactTestUtils.createRenderer(); - const wrapper = renderer.getRenderOutput( {}} />); + const renderer = new ShallowRenderer( {}} />); + const wrapper = renderer.getRenderOutput(); expect(wrapper).to.be.null; });