React connect decorator prevents hot module reloading
jetako opened this issue · comments
Jesse Cooper commented
The react/connect decorator prevents webpack and react-native hot module reloading. As far as I'm aware, React HMR doesn't work with pure functional components. This is an easy fix, simply change the innermost return value of connect()
to a class instead of a function:
export default function connect(mapToProps, actions = {}) {
return Child => (
class ConnectWrapper extends React.Component<any> {
render() {
const { props } = this
return (
<Connect {...props} mapToProps={mapToProps} actions={actions}>
{mappedProps => <Child {...mappedProps} {...props} />}
</Connect>
)
}
}
)
}
I think this would go a long way towards adoption of redux-zero, which I absolutely love!
Matheus Lima commented
Thanks for this @jetako
Could you send this PR?
Jesse Cooper commented
Sure @matheusml, I'll send over a PR shortly :)