mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-03-29 00:38:18 +08:00
Use 'module.exports' over 'export default'
The use of CommonJS require in RN modules makes it simpler to use CommonJS exports everywhere.
This commit is contained in:
@@ -11,7 +11,7 @@ import Image from '../../components/Image'
|
||||
import Text from '../../components/Text'
|
||||
import View from '../../components/View'
|
||||
|
||||
export default {
|
||||
module.exports = {
|
||||
...AnimatedImplementation,
|
||||
View: AnimatedImplementation.createAnimatedComponent(View),
|
||||
Text: AnimatedImplementation.createAnimatedComponent(Text),
|
||||
|
||||
@@ -4,7 +4,7 @@ import ReactDOM from 'react-dom'
|
||||
import StyleSheet from '../StyleSheet'
|
||||
import View from '../../components/View'
|
||||
|
||||
export default class ReactNativeApp extends Component {
|
||||
class ReactNativeApp extends Component {
|
||||
static propTypes = {
|
||||
initialProps: PropTypes.object,
|
||||
rootComponent: PropTypes.any.isRequired,
|
||||
@@ -45,3 +45,5 @@ const styles = StyleSheet.create({
|
||||
bottom: 0
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = ReactNativeApp
|
||||
|
||||
@@ -24,7 +24,7 @@ type AppConfig = {
|
||||
/**
|
||||
* `AppRegistry` is the JS entry point to running all React Native apps.
|
||||
*/
|
||||
export default class AppRegistry {
|
||||
class AppRegistry {
|
||||
static getAppKeys(): Array<string> {
|
||||
return Object.keys(runnables)
|
||||
}
|
||||
@@ -88,3 +88,5 @@ export default class AppRegistry {
|
||||
ReactDOM.unmountComponentAtNode(rootTag)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AppRegistry
|
||||
|
||||
@@ -3,7 +3,7 @@ import invariant from 'fbjs/lib/invariant'
|
||||
const listeners = {}
|
||||
const eventTypes = [ 'change' ]
|
||||
|
||||
export default class AppState {
|
||||
class AppState {
|
||||
static get currentState() {
|
||||
switch (document.visibilityState) {
|
||||
case 'hidden':
|
||||
@@ -27,3 +27,5 @@ export default class AppState {
|
||||
delete listeners[handler]
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AppState
|
||||
|
||||
@@ -12,7 +12,7 @@ const mergeLocalStorageItem = (key, value) => {
|
||||
window.localStorage.setItem(key, nextValue)
|
||||
}
|
||||
|
||||
export default class AsyncStorage {
|
||||
class AsyncStorage {
|
||||
/**
|
||||
* Erases *all* AsyncStorage for the domain.
|
||||
*/
|
||||
@@ -157,3 +157,5 @@ export default class AsyncStorage {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AsyncStorage
|
||||
|
||||
@@ -23,9 +23,11 @@ const dimensions = {
|
||||
}
|
||||
}
|
||||
|
||||
export default class Dimensions {
|
||||
class Dimensions {
|
||||
static get(dimension: string): Object {
|
||||
invariant(dimensions[dimension], 'No dimension set for key ' + dimension)
|
||||
return dimensions[dimension]
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Dimensions
|
||||
|
||||
@@ -45,4 +45,4 @@ const InteractionManager = {
|
||||
addListener: () => {}
|
||||
}
|
||||
|
||||
export default InteractionManager
|
||||
module.exports = InteractionManager
|
||||
|
||||
@@ -76,4 +76,4 @@ const NetInfo = {
|
||||
}
|
||||
}
|
||||
|
||||
export default NetInfo
|
||||
module.exports = NetInfo
|
||||
|
||||
@@ -81,4 +81,4 @@ function normalizeNativeEvent(nativeEvent) {
|
||||
return mouse ? normalizeMouseEvent(nativeEvent) : normalizeTouchEvent(nativeEvent)
|
||||
}
|
||||
|
||||
export default normalizeNativeEvent
|
||||
module.exports = normalizeNativeEvent
|
||||
|
||||
@@ -11,7 +11,7 @@ import Dimensions from '../Dimensions'
|
||||
/**
|
||||
* PixelRatio gives access to the device pixel density.
|
||||
*/
|
||||
export default class PixelRatio {
|
||||
class PixelRatio {
|
||||
/**
|
||||
* Returns the device pixel density.
|
||||
*/
|
||||
@@ -45,3 +45,5 @@ export default class PixelRatio {
|
||||
return Math.round(layoutSize * ratio) / ratio
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PixelRatio
|
||||
|
||||
@@ -5,4 +5,4 @@ const Platform = {
|
||||
userAgent: canUseDOM ? window.navigator.userAgent : ''
|
||||
}
|
||||
|
||||
export default Platform
|
||||
module.exports = Platform
|
||||
|
||||
@@ -22,4 +22,4 @@ const BorderPropTypes = {
|
||||
borderLeftStyle: BorderStylePropType
|
||||
}
|
||||
|
||||
export default BorderPropTypes
|
||||
module.exports = BorderPropTypes
|
||||
|
||||
@@ -59,4 +59,4 @@ var colorPropType = function(isRequired, props, propName, componentName, locatio
|
||||
var ColorPropType = colorPropType.bind(null, false /* isRequired */);
|
||||
ColorPropType.isRequired = colorPropType.bind(null, true /* isRequired */);
|
||||
|
||||
export default ColorPropType
|
||||
module.exports = ColorPropType
|
||||
|
||||
@@ -51,4 +51,4 @@ const LayoutPropTypes = {
|
||||
top: numberOrString
|
||||
}
|
||||
|
||||
export default LayoutPropTypes
|
||||
module.exports = LayoutPropTypes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import prefixAll from 'inline-style-prefix-all'
|
||||
import hyphenate from './hyphenate'
|
||||
|
||||
export default class Store {
|
||||
class Store {
|
||||
constructor(
|
||||
initialState:Object = {},
|
||||
options:Object = { obfuscateClassNames: false }
|
||||
@@ -95,3 +95,5 @@ export default class Store {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Store
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import createStrictShapeTypeChecker from './createStrictShapeTypeChecker'
|
||||
import flattenStyle from './flattenStyle'
|
||||
|
||||
export default function StyleSheetPropType(shape) {
|
||||
module.exports = function StyleSheetPropType(shape) {
|
||||
const shapePropType = createStrictShapeTypeChecker(shape)
|
||||
return function (props, propName, componentName, location?) {
|
||||
let newProps = props
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import prefixAll from 'inline-style-prefix-all'
|
||||
import flattenStyle from './flattenStyle'
|
||||
|
||||
export default class StyleSheetRegistry {
|
||||
class StyleSheetRegistry {
|
||||
static registerStyle(style: Object, store): number {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Object.freeze(style)
|
||||
@@ -44,3 +44,5 @@ export default class StyleSheetRegistry {
|
||||
return { className: _className, style: _style }
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StyleSheetRegistry
|
||||
|
||||
@@ -12,7 +12,7 @@ import TextStylePropTypes from '../../components/Text/TextStylePropTypes'
|
||||
import ViewStylePropTypes from '../../components/View/ViewStylePropTypes'
|
||||
import invariant from 'fbjs/lib/invariant'
|
||||
|
||||
export default class StyleSheetValidation {
|
||||
class StyleSheetValidation {
|
||||
static validateStyleProp(prop, style, caller) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (allStylePropTypes[prop] === undefined) {
|
||||
@@ -66,3 +66,5 @@ StyleSheetValidation.addValidStylePropTypes({
|
||||
listStyle: PropTypes.string,
|
||||
verticalAlign: PropTypes.string
|
||||
})
|
||||
|
||||
module.exports = StyleSheetValidation
|
||||
|
||||
@@ -44,4 +44,4 @@ const TransformPropTypes = {
|
||||
transformMatrix: TransformMatrixPropType
|
||||
}
|
||||
|
||||
export default TransformPropTypes
|
||||
module.exports = TransformPropTypes
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import invariant from 'fbjs/lib/invariant'
|
||||
import ReactPropTypeLocationNames from 'react/lib/ReactPropTypeLocationNames'
|
||||
|
||||
export default function createStrictShapeTypeChecker(shapeTypes) {
|
||||
module.exports = function createStrictShapeTypeChecker(shapeTypes) {
|
||||
function checkType(isRequired, props, propName, componentName, location?) {
|
||||
if (!props[propName]) {
|
||||
if (isRequired) {
|
||||
|
||||
@@ -56,4 +56,4 @@ const expandStyle = (style) => {
|
||||
}, {})
|
||||
}
|
||||
|
||||
export default expandStyle
|
||||
module.exports = expandStyle
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import invariant from 'fbjs/lib/invariant'
|
||||
import expandStyle from './expandStyle'
|
||||
|
||||
export default function flattenStyle(style): ?Object {
|
||||
module.exports = function flattenStyle(style): ?Object {
|
||||
if (!style) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export default (string) => (string.replace(/([A-Z])/g, '-$1').toLowerCase()).replace(/^ms-/, '-ms-')
|
||||
module.exports = (string) => (string.replace(/([A-Z])/g, '-$1').toLowerCase()).replace(/^ms-/, '-ms-')
|
||||
|
||||
@@ -65,7 +65,7 @@ const resolve = ({ style = {} }) => {
|
||||
return StyleSheetRegistry.getStyleAsNativeProps(style, store)
|
||||
}
|
||||
|
||||
export default {
|
||||
module.exports = {
|
||||
_destroy,
|
||||
_renderToString,
|
||||
create,
|
||||
|
||||
@@ -30,4 +30,4 @@ const normalizeValue = (property, value) => {
|
||||
return value
|
||||
}
|
||||
|
||||
export default normalizeValue
|
||||
module.exports = normalizeValue
|
||||
|
||||
@@ -32,4 +32,4 @@ const UIManager = {
|
||||
}
|
||||
}
|
||||
|
||||
export default UIManager
|
||||
module.exports = UIManager
|
||||
|
||||
@@ -20,7 +20,7 @@ const keyframeEffects = [
|
||||
]
|
||||
|
||||
@NativeMethodsDecorator
|
||||
export default class ActivityIndicator extends Component {
|
||||
class ActivityIndicator extends Component {
|
||||
static propTypes = {
|
||||
animating: PropTypes.bool,
|
||||
color: PropTypes.string,
|
||||
@@ -107,3 +107,5 @@ const indicatorStyles = StyleSheet.create({
|
||||
height: 36
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = ActivityIndicator
|
||||
|
||||
@@ -19,7 +19,7 @@ const roleComponents = {
|
||||
}
|
||||
|
||||
@NativeMethodsDecorator
|
||||
export default class CoreComponent extends Component {
|
||||
class CoreComponent extends Component {
|
||||
static propTypes = {
|
||||
accessibilityLabel: PropTypes.string,
|
||||
accessibilityLiveRegion: PropTypes.oneOf([ 'assertive', 'off', 'polite' ]),
|
||||
@@ -64,3 +64,5 @@ export default class CoreComponent extends Component {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CoreComponent
|
||||
|
||||
@@ -7,4 +7,4 @@ const ImageResizeMode = keyMirror({
|
||||
stretch: null
|
||||
})
|
||||
|
||||
export default ImageResizeMode
|
||||
module.exports = ImageResizeMode
|
||||
|
||||
@@ -6,7 +6,7 @@ import ImageResizeMode from './ImageResizeMode'
|
||||
|
||||
const hiddenOrVisible = PropTypes.oneOf([ 'hidden', 'visible' ])
|
||||
|
||||
export default {
|
||||
module.exports = {
|
||||
...LayoutPropTypes,
|
||||
...TransformPropTypes,
|
||||
backfaceVisibility: hiddenOrVisible,
|
||||
|
||||
@@ -23,7 +23,7 @@ const ImageSourcePropType = PropTypes.oneOfType([
|
||||
])
|
||||
|
||||
@NativeMethodsDecorator
|
||||
export default class Image extends Component {
|
||||
class Image extends Component {
|
||||
static propTypes = {
|
||||
accessibilityLabel: CoreComponent.propTypes.accessibilityLabel,
|
||||
accessible: CoreComponent.propTypes.accessible,
|
||||
@@ -217,3 +217,5 @@ const resizeModeStyles = StyleSheet.create({
|
||||
backgroundSize: '100% 100%'
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = Image
|
||||
|
||||
@@ -2,4 +2,4 @@ function resolveAssetSource(source) {
|
||||
return ((typeof source === 'object') ? source.uri : source) || null
|
||||
}
|
||||
|
||||
export default resolveAssetSource
|
||||
module.exports = resolveAssetSource
|
||||
|
||||
@@ -3,7 +3,7 @@ import React, { Component, PropTypes } from 'react'
|
||||
import ScrollView from '../ScrollView'
|
||||
|
||||
@NativeMethodsDecorator
|
||||
export default class ListView extends Component {
|
||||
class ListView extends Component {
|
||||
static propTypes = {
|
||||
children: PropTypes.any,
|
||||
style: ScrollView.propTypes.style
|
||||
@@ -19,3 +19,5 @@ export default class ListView extends Component {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ListView
|
||||
|
||||
@@ -19,7 +19,7 @@ let lastUsedTag = 0
|
||||
/**
|
||||
* A container that renders all the modals on top of everything else in the application.
|
||||
*/
|
||||
export default class Portal extends Component {
|
||||
class Portal extends Component {
|
||||
static propTypes = {
|
||||
onModalVisibilityChanged: PropTypes.func.isRequired
|
||||
};
|
||||
@@ -154,3 +154,5 @@ const styles = StyleSheet.create({
|
||||
bottom: 0
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = Portal
|
||||
|
||||
@@ -128,3 +128,5 @@ const styles = StyleSheet.create({
|
||||
flexDirection: 'row'
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = ScrollView
|
||||
|
||||
@@ -23,7 +23,7 @@ import React, { Component, PropTypes } from 'react'
|
||||
* Typically, you will not need to use this component and should opt for normal
|
||||
* React reconciliation.
|
||||
*/
|
||||
export default class StaticContainer extends Component {
|
||||
class StaticContainer extends Component {
|
||||
static propTypes = {
|
||||
children: PropTypes.any.isRequired,
|
||||
shouldUpdate: PropTypes.bool.isRequired
|
||||
@@ -38,3 +38,5 @@ export default class StaticContainer extends Component {
|
||||
return (child === null || child === false) ? null : React.Children.only(child)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StaticContainer
|
||||
|
||||
@@ -22,7 +22,7 @@ import { Component, PropTypes } from 'react'
|
||||
* React reconciliation.
|
||||
*/
|
||||
|
||||
export default class StaticRenderer extends Component {
|
||||
class StaticRenderer extends Component {
|
||||
static propTypes = {
|
||||
render: PropTypes.func.isRequired,
|
||||
shouldUpdate: PropTypes.bool.isRequired
|
||||
@@ -36,3 +36,5 @@ export default class StaticRenderer extends Component {
|
||||
return this.props.render()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StaticRenderer
|
||||
|
||||
@@ -5,7 +5,7 @@ import ViewStylePropTypes from '../View/ViewStylePropTypes'
|
||||
const { number, oneOf, oneOfType, string } = PropTypes
|
||||
const numberOrString = oneOfType([ number, string ])
|
||||
|
||||
export default {
|
||||
module.exports = {
|
||||
...ViewStylePropTypes,
|
||||
color: ColorPropType,
|
||||
fontFamily: string,
|
||||
|
||||
@@ -6,7 +6,7 @@ import StyleSheetPropType from '../../apis/StyleSheet/StyleSheetPropType'
|
||||
import TextStylePropTypes from './TextStylePropTypes'
|
||||
|
||||
@NativeMethodsDecorator
|
||||
export default class Text extends Component {
|
||||
class Text extends Component {
|
||||
static propTypes = {
|
||||
accessibilityLabel: CoreComponent.propTypes.accessibilityLabel,
|
||||
accessibilityRole: CoreComponent.propTypes.accessibilityRole,
|
||||
@@ -66,3 +66,5 @@ const styles = StyleSheet.create({
|
||||
whiteSpace: 'nowrap'
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = Text
|
||||
|
||||
@@ -8,7 +8,7 @@ import TextareaAutosize from 'react-textarea-autosize'
|
||||
import View from '../View'
|
||||
|
||||
@NativeMethodsDecorator
|
||||
export default class TextInput extends Component {
|
||||
class TextInput extends Component {
|
||||
static propTypes = {
|
||||
...View.propTypes,
|
||||
autoComplete: PropTypes.bool,
|
||||
@@ -229,3 +229,5 @@ const styles = StyleSheet.create({
|
||||
whiteSpace: 'pre'
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = TextInput
|
||||
|
||||
@@ -8,7 +8,7 @@ const { number, oneOf, string } = PropTypes
|
||||
const autoOrHiddenOrVisible = oneOf([ 'auto', 'hidden', 'visible' ])
|
||||
const hiddenOrVisible = oneOf([ 'hidden', 'visible' ])
|
||||
|
||||
export default {
|
||||
module.exports = {
|
||||
...BorderPropTypes,
|
||||
...LayoutPropTypes,
|
||||
...TransformPropTypes,
|
||||
|
||||
@@ -6,7 +6,7 @@ import StyleSheetPropType from '../../apis/StyleSheet/StyleSheetPropType'
|
||||
import ViewStylePropTypes from './ViewStylePropTypes'
|
||||
|
||||
@NativeMethodsDecorator
|
||||
export default class View extends Component {
|
||||
class View extends Component {
|
||||
static propTypes = {
|
||||
accessibilityLabel: CoreComponent.propTypes.accessibilityLabel,
|
||||
accessibilityLiveRegion: CoreComponent.propTypes.accessibilityLiveRegion,
|
||||
@@ -185,3 +185,5 @@ const styles = StyleSheet.create({
|
||||
textAlign: 'inherit'
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = View
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
// NativeModules shim
|
||||
const NativeModules = {}
|
||||
export default NativeModules
|
||||
module.exports = {}
|
||||
|
||||
Reference in New Issue
Block a user