Skip to content

Instantly share code, notes, and snippets.

@Sawtaytoes
Last active September 20, 2018 04:55
Show Gist options
  • Save Sawtaytoes/dea5a23bbf136d84e600043c7a1c1de3 to your computer and use it in GitHub Desktop.
Save Sawtaytoes/dea5a23bbf136d84e600043c7a1c1de3 to your computer and use it in GitHub Desktop.
Attempt at replacing react-redux's `connect` HoC with a `render` prop.
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