Created
April 21, 2020 15:15
-
-
Save AndreiCalazans/73b60c969e86614e0f146f9e79c96e78 to your computer and use it in GitHub Desktop.
Extended Redux Connect Function to call unmount.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extendedConnect(mapStateToProps, mapDispatchToProps) { | |
return function(WrappedComponent) { | |
return _default( | |
mapStateToProps, | |
mapDispatchToProps | |
)( | |
class UnmountSelectorWrapper extends React.Component { | |
componentWillUnmount() { | |
if (mapStateToProps && 'unmount' in mapStateToProps) { | |
mapStateToProps.unmount(); | |
} | |
} | |
render() { | |
return <WrappedComponent {...this.props} />; | |
} | |
} | |
); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace the
node_modules/react-redux/lib/connect/connect.js
with: