We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7bcdad3 commit 4d70a7eCopy full SHA for 4d70a7e
react-redux-connect.js
@@ -0,0 +1,18 @@
1
+// crude implementation of react redux connect using hoc
2
+
3
+import React,{Component} from "react";
4
5
+const connect = (ChildComponent, mapStateToProps, mapDispatchToProps) => {
6
7
+ return class Container extends Component{
8
9
+ render(){
10
+ const state = this.context.store.getState();
11
+ const dispatch = this.context.store.dispatch;
12
+ const stateToProps = mapStateToProps(state);
13
+ const dispatchToProps = mapDispatchToProps(dispatch);
14
+ return <ChildComponent {...this.props} {...stateToProps} {...dispatchToProps} />
15
+ }
16
17
18
+};
0 commit comments