@@ -36,6 +36,7 @@ export default function component(options = {}) {
36
36
instanceProps,
37
37
componentDidMount,
38
38
componentWillUnmount,
39
+ componentWillReceiveProps,
39
40
...rest
40
41
} = options ;
41
42
let { actions, watcher } = options ;
@@ -46,8 +47,7 @@ export default function component(options = {}) {
46
47
const setState = ( newState ) => this . setState ( { ...newState } ) ;
47
48
const getState = ( ) => this . state ;
48
49
const _self = this ;
49
-
50
- this . state = state || { } ;
50
+ this . state = state ( props ) || { } ;
51
51
this . __store__ = Wrapper . __store__ ;
52
52
53
53
if ( this . __store__ ) {
@@ -56,10 +56,11 @@ export default function component(options = {}) {
56
56
}
57
57
58
58
const pluck = getProps ( watcher ) ;
59
+ const instancePropsClone = { ...instanceProps }
59
60
// Attach handlers
60
61
bindHandler . call ( this , actions , store . action ) ;
61
62
bindHandler . call ( this , rest , this . proxy ) ;
62
- attachInstanceProps . call ( this , instanceProps ) ;
63
+ attachInstanceProps . call ( this , instancePropsClone ) ;
63
64
64
65
let globalState = this . __store__ ? pluck ( store ? store . getState ( ) : { } ) : { } ;
65
66
@@ -102,6 +103,11 @@ export default function component(options = {}) {
102
103
}
103
104
componentWillUnmount && componentWillUnmount . call ( null , this . mergeProps ( ) ) ;
104
105
}
106
+
107
+ this . componentWillReceiveProps = ( nxtProps ) => {
108
+ componentWillReceiveProps && componentWillReceiveProps . call ( null , nxtProps , this . mergeProps ( ) )
109
+ }
110
+
105
111
this . render = ( props ) => {
106
112
const view = template || InnerComponent ;
107
113
return h ( view , this . mergeProps ( ) ) ;
0 commit comments