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

114
Views
Pasar elemento HTML como accesorio con otros accesorios

Tengo un componente donde necesito pasar un elemento HTML como apoyo a otro elemento

 const MyText = () => { return ( <> <h1>Sample heading</h1> </> ) } return ( <div> <MyComponent Text={MyText} onClose={() => setShow(false)} show={show} /> </div> );

MiComponente.js

 export default function MyComponent(props) { return ( <> {props.Text} </> ); }

Problema: no obtengo nada renderizado en la pantalla. ¿Me estoy perdiendo de algo?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hay dos maneras.

Opción 1: pasar un tipo de componente (o clase si viene del fondo OOP)

 const MyText = () => { return ( <> <h1>Sample heading</h1> </> ) } return ( <div> <MyComponent Text={MyText} onClose={() => setShow(false)} show={show} /> </div> ); const MyComponent = ({ Text }) => { return ( <> <Text /> </> ); }

Opción 2: pasar un componente (o una instancia si viene del fondo OOP)

 const MyText = () => { return ( <> <h1>Sample heading</h1> </> ) } return ( <div> <MyComponent text={<MyText />} onClose={() => setShow(false)} show={show} /> </div> ); const MyComponent = ({ text }) => { return ( <> {text} </> ); }
about 4 years ago · Juan Pablo Isaza Report
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!