79455745

Date: 2025-02-20 20:22:45
Score: 1.5
Natty:
Report link

I'm not sure why Ariel's solution was downvoted, as it is one of the standard ways to do this with React. Having a prop with React.ComponentType<PropsType> is one of the most efficient and clear ways to do this. Note that this usually requires you to have another prop of type PropsType that is then used to instantiate the component.

interface ParentProps {
  component: React.Component<CType>
  componentProps: CType
}

...
// in Parent
const Component = component // to get uppercase
<Component {...componentProps} />

Reasons:
  • RegEx Blacklisted phrase (2): downvote
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Artemis Prime