diff --git a/src/components/ActivityIndicator/index.js b/src/components/ActivityIndicator/index.js index 6a456287..40d22b2b 100644 --- a/src/components/ActivityIndicator/index.js +++ b/src/components/ActivityIndicator/index.js @@ -1,4 +1,4 @@ -import { NativeMethodsDecorator } from '../../modules/NativeMethodsMixin' +import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import React, { Component, PropTypes } from 'react' import ReactDOM from 'react-dom' import StyleSheet from '../../apis/StyleSheet' diff --git a/src/components/CoreComponent/index.js b/src/components/CoreComponent/index.js index 72dda200..64d7048a 100644 --- a/src/components/CoreComponent/index.js +++ b/src/components/CoreComponent/index.js @@ -1,4 +1,4 @@ -import { NativeMethodsDecorator } from '../../modules/NativeMethodsMixin' +import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import React, { Component, PropTypes } from 'react' import StyleSheet from '../../apis/StyleSheet' diff --git a/src/components/Image/index.js b/src/components/Image/index.js index 6753686b..f804e3ee 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -1,5 +1,5 @@ /* global window */ -import { NativeMethodsDecorator } from '../../modules/NativeMethodsMixin' +import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import resolveAssetSource from './resolveAssetSource' import CoreComponent from '../CoreComponent' import ImageResizeMode from './ImageResizeMode' diff --git a/src/components/ListView/index.js b/src/components/ListView/index.js index bed504e5..bd316527 100644 --- a/src/components/ListView/index.js +++ b/src/components/ListView/index.js @@ -1,4 +1,4 @@ -import { NativeMethodsDecorator } from '../../modules/NativeMethodsMixin' +import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import React, { Component, PropTypes } from 'react' import ScrollView from '../ScrollView' diff --git a/src/components/Text/index.js b/src/components/Text/index.js index 87a0671a..be52666f 100644 --- a/src/components/Text/index.js +++ b/src/components/Text/index.js @@ -1,4 +1,4 @@ -import { NativeMethodsDecorator } from '../../modules/NativeMethodsMixin' +import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import CoreComponent from '../CoreComponent' import React, { Component, PropTypes } from 'react' import StyleSheet from '../../apis/StyleSheet' diff --git a/src/components/TextInput/index.js b/src/components/TextInput/index.js index c3955bfc..ee8d6efb 100644 --- a/src/components/TextInput/index.js +++ b/src/components/TextInput/index.js @@ -1,4 +1,4 @@ -import { NativeMethodsDecorator } from '../../modules/NativeMethodsMixin' +import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' import CoreComponent from '../CoreComponent' import React, { Component, PropTypes } from 'react' import ReactDOM from 'react-dom' diff --git a/src/components/View/index.js b/src/components/View/index.js index d70fd5f3..c584ac12 100644 --- a/src/components/View/index.js +++ b/src/components/View/index.js @@ -1,4 +1,5 @@ -import { NativeMethodsDecorator } from '../../modules/NativeMethodsMixin' +import NativeMethodsDecorator from '../../modules/NativeMethodsDecorator' +import normalizeNativeEvent from '../../apis/PanResponder/normalizeNativeEvent' import CoreComponent from '../CoreComponent' import React, { Component, PropTypes } from 'react' import StyleSheet from '../../apis/StyleSheet' diff --git a/src/modules/NativeMethodsDecorator/index.js b/src/modules/NativeMethodsDecorator/index.js new file mode 100644 index 00000000..9ca4e71d --- /dev/null +++ b/src/modules/NativeMethodsDecorator/index.js @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2015-present, Nicolas Gallagher. + * All rights reserved. + * + * @flow + */ + +import NativeMethodsMixin from '../NativeMethodsMixin' + +const NativeMethodsDecorator = (Component) => { + Object.keys(NativeMethodsMixin).forEach((method) => { + if (!Component.prototype[method]) { + Component.prototype[method] = NativeMethodsMixin[method] + } + }) + return Component +} + +module.exports = NativeMethodsDecorator diff --git a/src/modules/NativeMethodsMixin/index.js b/src/modules/NativeMethodsMixin/index.js index aadbf528..582030bd 100644 --- a/src/modules/NativeMethodsMixin/index.js +++ b/src/modules/NativeMethodsMixin/index.js @@ -90,11 +90,4 @@ const mountSafeCallback = (context: Component, callback: ?Function) => () => { return callback.apply(context, arguments) } -export const NativeMethodsDecorator = (Component) => { - Object.keys(NativeMethodsMixin).forEach((method) => { - Component.prototype[method] = NativeMethodsMixin[method] - }) - return Component -} - -export default NativeMethodsMixin +module.exports = NativeMethodsMixin