Skip to content

Commit ab1bfda

Browse files
committed
Use ES2015 module syntax again
This reverts commit caae2e1.
1 parent 3a96902 commit ab1bfda

File tree

7 files changed

+19
-31
lines changed

7 files changed

+19
-31
lines changed

src/components/Provider.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { Component, PropTypes, Children } = require('react')
2-
const storeShape = require('../utils/storeShape')
1+
import { Component, PropTypes, Children } from 'react'
2+
import storeShape from '../utils/storeShape'
33

44
let didWarnAboutReceivingStore = false
55
function warnAboutReceivingStore() {
@@ -17,7 +17,7 @@ function warnAboutReceivingStore() {
1717
)
1818
}
1919

20-
class Provider extends Component {
20+
export default class Provider extends Component {
2121
getChildContext() {
2222
return { store: this.store }
2323
}
@@ -49,5 +49,3 @@ Provider.propTypes = {
4949
Provider.childContextTypes = {
5050
store: storeShape.isRequired
5151
}
52-
53-
module.exports = Provider

src/components/connect.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const { Component, createElement } = require('react')
2-
const storeShape = require('../utils/storeShape')
3-
const shallowEqual = require('../utils/shallowEqual')
4-
const isPlainObject = require('../utils/isPlainObject')
5-
const wrapActionCreators = require('../utils/wrapActionCreators')
6-
const hoistStatics = require('hoist-non-react-statics')
7-
const invariant = require('invariant')
1+
import { Component, createElement } from 'react'
2+
import storeShape from '../utils/storeShape'
3+
import shallowEqual from '../utils/shallowEqual'
4+
import isPlainObject from '../utils/isPlainObject'
5+
import wrapActionCreators from '../utils/wrapActionCreators'
6+
import hoistStatics from 'hoist-non-react-statics'
7+
import invariant from 'invariant'
88

99
const defaultMapStateToProps = state => ({}) // eslint-disable-line no-unused-vars
1010
const defaultMapDispatchToProps = dispatch => ({ dispatch })
@@ -21,7 +21,7 @@ function getDisplayName(WrappedComponent) {
2121
// Helps track hot reloading.
2222
let nextVersion = 0
2323

24-
function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) {
24+
export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) {
2525
const shouldSubscribe = Boolean(mapStateToProps)
2626
const finalMapStateToProps = mapStateToProps || defaultMapStateToProps
2727
const finalMapDispatchToProps = isPlainObject(mapDispatchToProps) ?
@@ -273,5 +273,3 @@ function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {})
273273
return hoistStatics(Connect, WrappedComponent)
274274
}
275275
}
276-
277-
module.exports = connect

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const Provider = require('./components/Provider')
2-
const connect = require('./components/connect')
1+
import Provider from './components/Provider'
2+
import connect from './components/connect'
33

4-
module.exports = { Provider, connect }
4+
export { Provider, connect }

src/utils/isPlainObject.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const fnToString = (fn) => Function.prototype.toString.call(fn)
44
* @param {any} obj The object to inspect.
55
* @returns {boolean} True if the argument appears to be a plain object.
66
*/
7-
function isPlainObject(obj) {
7+
export default function isPlainObject(obj) {
88
if (!obj || typeof obj !== 'object') {
99
return false
1010
}
@@ -23,5 +23,3 @@ function isPlainObject(obj) {
2323
&& constructor instanceof constructor
2424
&& fnToString(constructor) === fnToString(Object)
2525
}
26-
27-
module.exports = isPlainObject

src/utils/shallowEqual.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function shallowEqual(objA, objB) {
1+
export default function shallowEqual(objA, objB) {
22
if (objA === objB) {
33
return true
44
}
@@ -21,5 +21,3 @@ function shallowEqual(objA, objB) {
2121

2222
return true
2323
}
24-
25-
module.exports = shallowEqual

src/utils/storeShape.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
const { PropTypes } = require('react')
1+
import { PropTypes } from 'react'
22

3-
const storeShape = PropTypes.shape({
3+
export default PropTypes.shape({
44
subscribe: PropTypes.func.isRequired,
55
dispatch: PropTypes.func.isRequired,
66
getState: PropTypes.func.isRequired
77
})
8-
9-
module.exports = storeShape

src/utils/wrapActionCreators.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { bindActionCreators } from 'redux'
22

3-
function wrapActionCreators(actionCreators) {
3+
export default function wrapActionCreators(actionCreators) {
44
return dispatch => bindActionCreators(actionCreators, dispatch)
55
}
6-
7-
module.exports = wrapActionCreators

0 commit comments

Comments
 (0)