Skip to content

Commit

Permalink
Use ES2015 module syntax again
Browse files Browse the repository at this point in the history
This reverts commit caae2e1.
  • Loading branch information
flying-sheep committed Jan 19, 2016
1 parent 3a96902 commit ab1bfda
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 31 deletions.
8 changes: 3 additions & 5 deletions src/components/Provider.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -17,7 +17,7 @@ function warnAboutReceivingStore() {
)
}

class Provider extends Component {
export default class Provider extends Component {
getChildContext() {
return { store: this.store }
}
Expand Down Expand Up @@ -49,5 +49,3 @@ Provider.propTypes = {
Provider.childContextTypes = {
store: storeShape.isRequired
}

module.exports = Provider
18 changes: 8 additions & 10 deletions src/components/connect.js
Original file line number Diff line number Diff line change
@@ -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 })
Expand All @@ -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) ?
Expand Down Expand Up @@ -273,5 +273,3 @@ function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {})
return hoistStatics(Connect, WrappedComponent)
}
}

module.exports = connect
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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 }
4 changes: 1 addition & 3 deletions src/utils/isPlainObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -23,5 +23,3 @@ function isPlainObject(obj) {
&& constructor instanceof constructor
&& fnToString(constructor) === fnToString(Object)
}

module.exports = isPlainObject
4 changes: 1 addition & 3 deletions src/utils/shallowEqual.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function shallowEqual(objA, objB) {
export default function shallowEqual(objA, objB) {
if (objA === objB) {
return true
}
Expand All @@ -21,5 +21,3 @@ function shallowEqual(objA, objB) {

return true
}

module.exports = shallowEqual
6 changes: 2 additions & 4 deletions src/utils/storeShape.js
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions src/utils/wrapActionCreators.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { bindActionCreators } from 'redux'

function wrapActionCreators(actionCreators) {
export default function wrapActionCreators(actionCreators) {
return dispatch => bindActionCreators(actionCreators, dispatch)
}

module.exports = wrapActionCreators

0 comments on commit ab1bfda

Please sign in to comment.