1

I am trying to return a component without a set name at runtime. Like so:

<div className="project-demo">
  <CustomComponent demo={project.demo}/>
</div>

and being called like this:

const CustomComponent = ({ demo }) => {

  return (
    <{ demo } />    
  )
}

Any advice?

1
  • Can you elaborate on the problem you are trying to solve? I don't think what you are trying to do is recommended. Commented Aug 2, 2020 at 3:17

1 Answer 1

2

JSX expects components to have capitalized names

const CustomComponent = ({ demo }) => {
  const Demo = demo;
  
  return (
    <Demo />
  )
}

or better:

const CustomComponent = ({ Demo }) => {  
  return (
    <Demo />
  )
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.