Last active
September 20, 2018 04:55
-
-
Save Sawtaytoes/dea5a23bbf136d84e600043c7a1c1de3 to your computer and use it in GitHub Desktop.
Attempt at replacing react-redux's `connect` HoC with a `render` prop.
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
import PropTypes from 'prop-types' | |
import { connect } from 'react-redux' | |
export const ReduxConnect = ({ | |
mapDispatchToProps, | |
mapStateToProps, | |
render, | |
}) => ( | |
connect( | |
(mapStateToProps || null), | |
mapDispatchToProps | |
)( | |
render | |
) | |
) | |
ReduxConnect.propTypes = { | |
mapDispatchToProps: PropTypes.any, | |
mapStateToProps: PropTypes.func, | |
render: PropTypes.func.isRequired, | |
} | |
export default ReduxConnect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment