-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connected components not working with react-hot-loader #116
Labels
Comments
Is this with React, or Preact? |
React |
This is likely fixed by 1028258. |
Released as 3.2.0. Please re-open this issue if its still there in 3.2.0. |
I'm sorry for taking so long to answer, but this issue is still there with the latest release. However I was able to mitigate the issue by rewriting the connect function using classes, the following code receives updates properly: export function connect(mapToProps, actions) {
if (typeof mapToProps !== 'function') {
mapToProps = select(mapToProps || []);
}
return Child => class Wrapper extends PureComponent {
state = mapToProps(store.getState());
update = state => this.setState(mapToProps(state));
boundActions = actions ? mapActions(actions, store) : { store };
componentWillMount() {
store.subscribe(this.update);
}
componentWillUnmount() {
store.unsubscribe(this.update);
}
render() {
return createElement(
Child,
Object.assign(this.boundActions, this.props, this.state)
);
}
};
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Components wrapped with connect are not updated after a hot reload, only components without the connect wrapper get their hot updates.
The text was updated successfully, but these errors were encountered: