Skip to content

Commit 38f3332

Browse files
committed
meger default props with given props
1 parent e032931 commit 38f3332

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/react-most.es6

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import initHistory from './history'
33
import mostEngine from './engine/most'
4+
import merge from 'ramda/src/merge'
45
// unfortunately React doesn't support symbol as context key yet, so let me just preteding using Symbol until react implement the Symbol version of Object.assign
56
const intentStream = "__reactive.react.intentStream__";
67
const historyStream = "__reactive.react.historyStream__";
@@ -21,7 +22,7 @@ export function connect(main, initprops={}) {
2122
class Connect extends React.Component {
2223
constructor(props, context) {
2324
super(props, context);
24-
this.state = ReactClass.defaultProps
25+
this.state = merge(ReactClass.defaultProps, props)
2526
if(props.history) initprops.history=true
2627
this.actions = {
2728
fromEvent(e){
@@ -68,7 +69,7 @@ export function connect(main, initprops={}) {
6869
});
6970
}
7071
render() {
71-
return <ReactClass {...initprops} {...this.props} {...this.state} actions={this.actions} />
72+
return <ReactClass {...this.state} actions={this.actions} />
7273
}
7374
}
7475
Connect.contextTypes = CONTEXT_TYPE;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"dependencies": {
2727
"most": "^1.0.5",
2828
"most-subject": "^5.2.0",
29+
"ramda": "^0.22.1",
2930
"react": "^15.3.2",
3031
"rx": "^4.1.0"
3132
},
@@ -48,9 +49,9 @@
4849
"babelify": "^7.2.0",
4950
"jest": "^16.0.2",
5051
"jest-cli": "^16.0.2",
52+
"lodash": "^4.0.0",
5153
"react-addons-test-utils": "^15.2.0",
5254
"react-dom": "^15.3.2",
53-
"lodash": "^4.0.0",
5455
"redux": "^3.0.4"
5556
},
5657
"author": "Jichao Ouyang",

0 commit comments

Comments
 (0)