-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I was using this in a project based on the latest create-react-app and I was getting issues with arrow functions not having a prototype, which was causing the library to throw. It would be better to use react-is to check if the ComponentOrFunction is renderable with React.createElement.
import React from 'react'
import * as ReactIs from 'react-is'
const renderProps = (ComponentOrFunction, props) =>
ReactIs.isValidElementType(ComponentOrFunction)
? React.createElement(ComponentOrFunction, props)
: ComponentOrFunction({
...(ComponentOrFunction.defaultProps || {}),
...props,
})
export default renderPropsmarkerikson
Metadata
Metadata
Assignees
Labels
No labels