Skip to content

Commit f4ea60c

Browse files
authoredMar 30, 2021
Import bindActionCreators from redux (#1705)
1 parent 50b60e4 commit f4ea60c

File tree

5 files changed

+26276
-22
lines changed

5 files changed

+26276
-22
lines changed
 

‎package-lock.json

+26,263-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
"coverage": "codecov"
3737
},
3838
"peerDependencies": {
39-
"react": "^16.8.3 || ^17",
40-
"redux": "^2.0.0 || ^3.0.0 || ^4.0.0-0"
39+
"react": "^16.8.3 || ^17"
4140
},
4241
"peerDependenciesMeta": {
4342
"react-dom": {

‎src/connect/mapDispatchToProps.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { bindActionCreators } from 'redux'
1+
import bindActionCreators from '../utils/bindActionCreators'
22
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps'
33

44
export function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {

‎src/utils/bindActionCreators.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default function bindActionCreators(actionCreators, dispatch) {
2+
const boundActionCreators = {}
3+
for (const key in actionCreators) {
4+
const actionCreator = actionCreators[key]
5+
if (typeof actionCreator === 'function') {
6+
boundActionCreators[key] = (...args) => dispatch(actionCreator(...args))
7+
}
8+
}
9+
return boundActionCreators
10+
}

‎src/utils/wrapActionCreators.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { bindActionCreators } from 'redux'
1+
import bindActionCreators from './bindActionCreators'
22

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

0 commit comments

Comments
 (0)
Please sign in to comment.