Created
June 6, 2018 15:31
-
-
Save jonsherrard/b8cd67b49fd8fb1df5ff026713a171a1 to your computer and use it in GitHub Desktop.
render pros normalizing stuff
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 React from 'react' | |
const renderProps = (ComponentOrFunction, props) => ( | |
ComponentOrFunction.propTypes || ComponentOrFunction.prototype.render | |
? <ComponentOrFunction {...props} /> | |
: ComponentOrFunction({ | |
...(ComponentOrFunction.defaultProps || {}), | |
...props, | |
}) | |
) | |
export default renderProps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment