From f0202dbe612864a1f7972eec462d5af066b2d335 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Wed, 6 Jul 2016 10:11:03 -0700 Subject: [PATCH] Remove use of decorator syntax --- src/components/ActivityIndicator/index.js | 5 +++-- src/components/Image/index.js | 5 +++-- src/components/ListView/index.js | 5 +++-- src/components/Text/index.js | 5 +++-- src/components/TextInput/index.js | 5 +++-- src/components/View/index.js | 5 +++-- .../{NativeMethodsDecorator => applyNativeMethods}/index.js | 4 ++-- 7 files changed, 20 insertions(+), 14 deletions(-) rename src/modules/{NativeMethodsDecorator => applyNativeMethods}/index.js (79%) diff --git a/src/components/ActivityIndicator/index.js b/src/components/ActivityIndicator/index.js index f2f60471..4fe2e6fe 100644 --- a/src/components/ActivityIndicator/index.js +++ b/src/components/ActivityIndicator/index.js @@ -1,4 +1,4 @@ -import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' +import applyNativeMethods from '../../modules/applyNativeMethods' import React, { Component, PropTypes } from 'react' import ReactDOM from 'react-dom' import StyleSheet from '../../apis/StyleSheet' @@ -19,7 +19,6 @@ const keyframeEffects = [ { transform: 'scale(0.95)', opacity: 0.5 } ] -@NativeMethodsDecorator class ActivityIndicator extends Component { static propTypes = { animating: PropTypes.bool, @@ -87,6 +86,8 @@ class ActivityIndicator extends Component { } } +applyNativeMethods(ActivityIndicator) + const styles = StyleSheet.create({ container: { alignItems: 'center', diff --git a/src/components/Image/index.js b/src/components/Image/index.js index cbc70e66..5d4367e7 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -1,8 +1,8 @@ /* global window */ +import applyNativeMethods from '../../modules/applyNativeMethods' import createNativeComponent from '../../modules/createNativeComponent' import ImageResizeMode from './ImageResizeMode' import ImageStylePropTypes from './ImageStylePropTypes' -import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import resolveAssetSource from './resolveAssetSource' import React, { Component, PropTypes } from 'react' import StyleSheet from '../../apis/StyleSheet' @@ -22,7 +22,6 @@ const ImageSourcePropType = PropTypes.oneOfType([ PropTypes.string ]) -@NativeMethodsDecorator class Image extends Component { static propTypes = { accessibilityLabel: createNativeComponent.propTypes.accessibilityLabel, @@ -176,6 +175,8 @@ class Image extends Component { } } +applyNativeMethods(Image) + const styles = StyleSheet.create({ initial: { alignSelf: 'flex-start', diff --git a/src/components/ListView/index.js b/src/components/ListView/index.js index 27813f93..ca5fe456 100644 --- a/src/components/ListView/index.js +++ b/src/components/ListView/index.js @@ -1,4 +1,4 @@ -import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' +import applyNativeMethods from '../../modules/applyNativeMethods' import React, { Component } from 'react' import ScrollView from '../ScrollView' import ListViewDataSource from './ListViewDataSource' @@ -6,7 +6,6 @@ import ListViewPropTypes from './ListViewPropTypes' const SCROLLVIEW_REF = 'listviewscroll' -@NativeMethodsDecorator class ListView extends Component { static propTypes = ListViewPropTypes; @@ -100,4 +99,6 @@ class ListView extends Component { } } +applyNativeMethods(ListView) + module.exports = ListView diff --git a/src/components/Text/index.js b/src/components/Text/index.js index 54738ce0..428db65e 100644 --- a/src/components/Text/index.js +++ b/src/components/Text/index.js @@ -1,11 +1,10 @@ +import applyNativeMethods from '../../modules/applyNativeMethods' import createNativeComponent from '../../modules/createNativeComponent' -import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import { Component, PropTypes } from 'react' import StyleSheet from '../../apis/StyleSheet' import StyleSheetPropType from '../../apis/StyleSheet/StyleSheetPropType' import TextStylePropTypes from './TextStylePropTypes' -@NativeMethodsDecorator class Text extends Component { static propTypes = { accessibilityLabel: createNativeComponent.propTypes.accessibilityLabel, @@ -49,6 +48,8 @@ class Text extends Component { } } +applyNativeMethods(Text) + const styles = StyleSheet.create({ initial: { color: 'inherit', diff --git a/src/components/TextInput/index.js b/src/components/TextInput/index.js index a804766d..2a7407ba 100644 --- a/src/components/TextInput/index.js +++ b/src/components/TextInput/index.js @@ -1,5 +1,5 @@ +import applyNativeMethods from '../../modules/applyNativeMethods' import createNativeComponent from '../../modules/createNativeComponent' -import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import omit from 'lodash/omit' import pick from 'lodash/pick' import React, { Component, PropTypes } from 'react' @@ -14,7 +14,6 @@ import ViewStylePropTypes from '../View/ViewStylePropTypes' const viewStyleProps = Object.keys(ViewStylePropTypes) -@NativeMethodsDecorator class TextInput extends Component { static propTypes = { ...View.propTypes, @@ -233,6 +232,8 @@ class TextInput extends Component { } } +applyNativeMethods(TextInput) + const styles = StyleSheet.create({ initial: { borderColor: 'black', diff --git a/src/components/View/index.js b/src/components/View/index.js index 04ccfaef..63303dff 100644 --- a/src/components/View/index.js +++ b/src/components/View/index.js @@ -1,12 +1,11 @@ +import applyNativeMethods from '../../modules/applyNativeMethods' import createNativeComponent from '../../modules/createNativeComponent' -import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import normalizeNativeEvent from '../../apis/PanResponder/normalizeNativeEvent' import { Component, PropTypes } from 'react' import StyleSheet from '../../apis/StyleSheet' import StyleSheetPropType from '../../apis/StyleSheet/StyleSheetPropType' import ViewStylePropTypes from './ViewStylePropTypes' -@NativeMethodsDecorator class View extends Component { static propTypes = { accessibilityLabel: createNativeComponent.propTypes.accessibilityLabel, @@ -98,6 +97,8 @@ class View extends Component { } } +applyNativeMethods(View) + const styles = StyleSheet.create({ // https://github.com/facebook/css-layout#default-values initial: { diff --git a/src/modules/NativeMethodsDecorator/index.js b/src/modules/applyNativeMethods/index.js similarity index 79% rename from src/modules/NativeMethodsDecorator/index.js rename to src/modules/applyNativeMethods/index.js index 9ca4e71d..8e9ca353 100644 --- a/src/modules/NativeMethodsDecorator/index.js +++ b/src/modules/applyNativeMethods/index.js @@ -7,7 +7,7 @@ import NativeMethodsMixin from '../NativeMethodsMixin' -const NativeMethodsDecorator = (Component) => { +const applyNativeMethods = (Component) => { Object.keys(NativeMethodsMixin).forEach((method) => { if (!Component.prototype[method]) { Component.prototype[method] = NativeMethodsMixin[method] @@ -16,4 +16,4 @@ const NativeMethodsDecorator = (Component) => { return Component } -module.exports = NativeMethodsDecorator +module.exports = applyNativeMethods