Skip to content

Commit e531375

Browse files
author
Orkun Tumer
committed
Fix for issue developit#169
1 parent f3a4e99 commit e531375

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/integrations/preact.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function connect(mapStateToProps, actions) {
2424
const store = context.store;
2525
let state = mapStateToProps(store ? store.getState() : {}, props);
2626
const boundActions = actions ? mapActions(actions, store) : { store };
27-
let update = () => {
27+
const update = () => {
2828
let mapped = mapStateToProps(store ? store.getState() : {}, props);
2929
for (let i in mapped) if (mapped[i]!==state[i]) {
3030
state = mapped;
@@ -35,13 +35,11 @@ export function connect(mapStateToProps, actions) {
3535
return this.setState({});
3636
}
3737
};
38+
store.subscribe(update);
3839
this.componentWillReceiveProps = p => {
3940
props = p;
4041
update();
4142
};
42-
this.componentDidMount = () => {
43-
store.subscribe(update);
44-
};
4543
this.componentWillUnmount = () => {
4644
store.unsubscribe(update);
4745
};

src/integrations/react.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ export function connect(mapStateToProps, actions) {
3939
return this.forceUpdate();
4040
}
4141
};
42+
store.subscribe(update);
4243
this.UNSAFE_componentWillReceiveProps = p => {
4344
props = p;
4445
update();
4546
};
46-
this.componentDidMount = () => {
47-
store.subscribe(update);
48-
};
4947
this.componentWillUnmount = () => {
5048
store.unsubscribe(update);
5149
};

0 commit comments

Comments
 (0)