Skip to content

Commit 47d6d85

Browse files
author
liyang90
committed
Call the original onLoad() and onUnload().
1 parent ffbbe32 commit 47d6d85

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/connect.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ function connect(mapStateToProps, mapDispatchToProps) {
3434
this.setData(mappedState)
3535
}
3636

37+
const {
38+
onLoad: _onLoad,
39+
onUnload: _onUnload,
40+
} = pageConfig
41+
3742
function onLoad(options) {
3843
this.store = app.store;
3944
if (!this.store) {
@@ -43,9 +48,15 @@ function connect(mapStateToProps, mapDispatchToProps) {
4348
this.unsubscribe = this.store.subscribe(handleChange.bind(this, options))
4449
handleChange.apply(this)
4550
}
51+
if (typeof _onLoad === 'function') {
52+
_onLoad.call(this, options)
53+
}
4654
}
4755

4856
function onUnload() {
57+
if (typeof _onUnload === 'function') {
58+
_onUnload.call(this)
59+
}
4960
typeof this.unsubscribe === 'function' && this.unsubscribe()
5061
}
5162

0 commit comments

Comments
 (0)