Skip to content

Instantly share code, notes, and snippets.

@jonsherrard
Created June 6, 2018 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonsherrard/b8cd67b49fd8fb1df5ff026713a171a1 to your computer and use it in GitHub Desktop.
Save jonsherrard/b8cd67b49fd8fb1df5ff026713a171a1 to your computer and use it in GitHub Desktop.
render pros normalizing stuff
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