Skip to content

Commit

Permalink
fix(redux): 修复小程序 redux 没有取消注册 stateListener 的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Aug 5, 2019
1 parent e2cb224 commit 5e0cb12
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/taro-redux/src/connect/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function connect (mapStateToProps, mapDispatchToProps) {
})

let unSubscribe = null

return class Connect extends Component {
constructor (props, isPage) {
super(Object.assign(...arguments, mergeObjects(mapStateToProps(store.getState(), props), initMapDispatch)), isPage)
Expand All @@ -66,6 +67,12 @@ export default function connect (mapStateToProps, mapDispatchToProps) {
}

_constructor () {
if (!this.$scope) {
if (super._constructor) {
super._constructor(this.props)
}
return
}
const store = getStore()
Object.assign(this.props, mergeObjects(mapStateToProps(store.getState(), this.props), initMapDispatch))
unSubscribe = store.subscribe(stateListener.bind(this))
Expand Down

0 comments on commit 5e0cb12

Please sign in to comment.