Skip to content

Commit e42cfd9

Browse files
committed
merge props by from inner to outer
1 parent 97872eb commit e42cfd9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/react-most.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +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'
4+
import mergeAll from 'ramda/src/mergeAll'
55
// 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
66
const intentStream = "__reactive.react.intentStream__";
77
const historyStream = "__reactive.react.historyStream__";
@@ -22,7 +22,8 @@ export function connect(main, initprops={}) {
2222
class Connect extends React.Component {
2323
constructor(props, context) {
2424
super(props, context);
25-
this.state = merge(ReactClass.defaultProps, props)
25+
// the outer props has higher piority
26+
this.state = mergeAll([ReactClass.defaultProps, initprops, props])
2627
if(props.history) initprops.history=true
2728
this.actions = {
2829
fromEvent(e){
@@ -36,6 +37,7 @@ export function connect(main, initprops={}) {
3637
let sinks = main(context[intentStream],props);
3738
let actionsSinks = []
3839
if(initprops.history){
40+
initprops = {}
3941
initprops.history = initHistory(context[historyStream])
4042
initprops.history.travel.observe(state=>{
4143
return this.setState(state)
@@ -69,7 +71,7 @@ export function connect(main, initprops={}) {
6971
});
7072
}
7173
render() {
72-
return <ReactClass {...this.state} actions={this.actions} />
74+
return <ReactClass {...this.state} {...initprops} actions={this.actions} />
7375
}
7476
}
7577
Connect.contextTypes = CONTEXT_TYPE;

0 commit comments

Comments
 (0)