Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
Define prop type as string or specific component

I am trying to figure something out, that just won't work. I have a component that accepts a type headline. The component needs to accept a string, or a specific component, but nothing else:

export interface Props {
  headline: string | Component
}

I have tried a combination of React.ElementType<typeof Component>, typeof Component, ComponentType<typeof Component>, none of it works, because it either just allows everything, or it allows nothing but the string at all. I have tried to pass the component as a function too, with headline={() => <Component />}, which eliminates all type errors but this won't render the passed component any longer.

This feels basic to me and I am not sure what the proper way to go about this would be. What is the right typing for this use case?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!