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

172
Views
pasar div a props reaccionar sin niños

Estoy tratando de pasar un <div></div> (algo de contenido html/jsx) a un FC pero no de los accesorios para niños (ya se usa para otra cosa).

Quiero tener algo así:

 <Component props={{ title: "hello", description: { <>Hello <h1>world</h1> </> } />

Cómo puedo hacer eso ?

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

0

Actualizar :

Puede usar Fragment si su versión es superior a 16.2:

como esto :

 <Child text={ <Fragment> This is an <strong>HTML</strong> string. </Fragment> } />

Versión antigua :

Puede usar dangerouslySetInnerHTML SetInnerHTML para representar un contenido HTML desde un accesorio.

pasar el html como un accesorio de cadena normal

<Component text="This is <strong>not</strong> working." />

Y renderizar en el código JSX de esta manera:

Ingresa el código aquí :

 <div className="header-title-right wow fadeInRight" dangerouslySetInnerHTML={{__html: props.text}} />

Solo tenga cuidado si está procesando datos ingresados por el usuario. Puedes ser víctima de un ataque XSS

Aquí está la documentación: https://facebook.github.io/react/tips/dangerously-set-inner-html.html

Ejemplo: demostración de trabajo

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!