Skip to content

Commit

Permalink
Fix for issue developit#169
Browse files Browse the repository at this point in the history
  • Loading branch information
Orkun Tumer committed Mar 10, 2021
1 parent f3a4e99 commit e531375
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/integrations/preact.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function connect(mapStateToProps, actions) {
const store = context.store;
let state = mapStateToProps(store ? store.getState() : {}, props);
const boundActions = actions ? mapActions(actions, store) : { store };
let update = () => {
const update = () => {
let mapped = mapStateToProps(store ? store.getState() : {}, props);
for (let i in mapped) if (mapped[i]!==state[i]) {
state = mapped;
Expand All @@ -35,13 +35,11 @@ export function connect(mapStateToProps, actions) {
return this.setState({});
}
};
store.subscribe(update);
this.componentWillReceiveProps = p => {
props = p;
update();
};
this.componentDidMount = () => {
store.subscribe(update);
};
this.componentWillUnmount = () => {
store.unsubscribe(update);
};
Expand Down
4 changes: 1 addition & 3 deletions src/integrations/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ export function connect(mapStateToProps, actions) {
return this.forceUpdate();
}
};
store.subscribe(update);
this.UNSAFE_componentWillReceiveProps = p => {
props = p;
update();
};
this.componentDidMount = () => {
store.subscribe(update);
};
this.componentWillUnmount = () => {
store.unsubscribe(update);
};
Expand Down

0 comments on commit e531375

Please sign in to comment.