From ab1bfda98384b745bdc4a30623ac556e9665a57b Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Sat, 16 Jan 2016 13:41:01 +0100 Subject: [PATCH] Use ES2015 module syntax again This reverts commit caae2e1d53775b89716683f7d6a5d8302cad5a87. --- src/components/Provider.js | 8 +++----- src/components/connect.js | 18 ++++++++---------- src/index.js | 6 +++--- src/utils/isPlainObject.js | 4 +--- src/utils/shallowEqual.js | 4 +--- src/utils/storeShape.js | 6 ++---- src/utils/wrapActionCreators.js | 4 +--- 7 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/components/Provider.js b/src/components/Provider.js index b62c0e6b1..d0e5ed7f0 100644 --- a/src/components/Provider.js +++ b/src/components/Provider.js @@ -1,5 +1,5 @@ -const { Component, PropTypes, Children } = require('react') -const storeShape = require('../utils/storeShape') +import { Component, PropTypes, Children } from 'react' +import storeShape from '../utils/storeShape' let didWarnAboutReceivingStore = false function warnAboutReceivingStore() { @@ -17,7 +17,7 @@ function warnAboutReceivingStore() { ) } -class Provider extends Component { +export default class Provider extends Component { getChildContext() { return { store: this.store } } @@ -49,5 +49,3 @@ Provider.propTypes = { Provider.childContextTypes = { store: storeShape.isRequired } - -module.exports = Provider diff --git a/src/components/connect.js b/src/components/connect.js index e9fbc06e5..a028b2f97 100644 --- a/src/components/connect.js +++ b/src/components/connect.js @@ -1,10 +1,10 @@ -const { Component, createElement } = require('react') -const storeShape = require('../utils/storeShape') -const shallowEqual = require('../utils/shallowEqual') -const isPlainObject = require('../utils/isPlainObject') -const wrapActionCreators = require('../utils/wrapActionCreators') -const hoistStatics = require('hoist-non-react-statics') -const invariant = require('invariant') +import { Component, createElement } from 'react' +import storeShape from '../utils/storeShape' +import shallowEqual from '../utils/shallowEqual' +import isPlainObject from '../utils/isPlainObject' +import wrapActionCreators from '../utils/wrapActionCreators' +import hoistStatics from 'hoist-non-react-statics' +import invariant from 'invariant' const defaultMapStateToProps = state => ({}) // eslint-disable-line no-unused-vars const defaultMapDispatchToProps = dispatch => ({ dispatch }) @@ -21,7 +21,7 @@ function getDisplayName(WrappedComponent) { // Helps track hot reloading. let nextVersion = 0 -function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) { +export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) { const shouldSubscribe = Boolean(mapStateToProps) const finalMapStateToProps = mapStateToProps || defaultMapStateToProps const finalMapDispatchToProps = isPlainObject(mapDispatchToProps) ? @@ -273,5 +273,3 @@ function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) return hoistStatics(Connect, WrappedComponent) } } - -module.exports = connect diff --git a/src/index.js b/src/index.js index 65a2e6c4a..ad89eec2d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -const Provider = require('./components/Provider') -const connect = require('./components/connect') +import Provider from './components/Provider' +import connect from './components/connect' -module.exports = { Provider, connect } +export { Provider, connect } diff --git a/src/utils/isPlainObject.js b/src/utils/isPlainObject.js index 5fc5ccc1c..cb8e86144 100644 --- a/src/utils/isPlainObject.js +++ b/src/utils/isPlainObject.js @@ -4,7 +4,7 @@ const fnToString = (fn) => Function.prototype.toString.call(fn) * @param {any} obj The object to inspect. * @returns {boolean} True if the argument appears to be a plain object. */ -function isPlainObject(obj) { +export default function isPlainObject(obj) { if (!obj || typeof obj !== 'object') { return false } @@ -23,5 +23,3 @@ function isPlainObject(obj) { && constructor instanceof constructor && fnToString(constructor) === fnToString(Object) } - -module.exports = isPlainObject diff --git a/src/utils/shallowEqual.js b/src/utils/shallowEqual.js index e10c4ae52..76df37841 100644 --- a/src/utils/shallowEqual.js +++ b/src/utils/shallowEqual.js @@ -1,4 +1,4 @@ -function shallowEqual(objA, objB) { +export default function shallowEqual(objA, objB) { if (objA === objB) { return true } @@ -21,5 +21,3 @@ function shallowEqual(objA, objB) { return true } - -module.exports = shallowEqual diff --git a/src/utils/storeShape.js b/src/utils/storeShape.js index c28b20d9e..16b1b141a 100644 --- a/src/utils/storeShape.js +++ b/src/utils/storeShape.js @@ -1,9 +1,7 @@ -const { PropTypes } = require('react') +import { PropTypes } from 'react' -const storeShape = PropTypes.shape({ +export default PropTypes.shape({ subscribe: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired, getState: PropTypes.func.isRequired }) - -module.exports = storeShape diff --git a/src/utils/wrapActionCreators.js b/src/utils/wrapActionCreators.js index ad4f48947..349e03d0f 100644 --- a/src/utils/wrapActionCreators.js +++ b/src/utils/wrapActionCreators.js @@ -1,7 +1,5 @@ import { bindActionCreators } from 'redux' -function wrapActionCreators(actionCreators) { +export default function wrapActionCreators(actionCreators) { return dispatch => bindActionCreators(actionCreators, dispatch) } - -module.exports = wrapActionCreators