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

141
Views
¿Cómo renderizar un componente que se pasa como accesorio en React?

Estoy tratando de renderizar mis páginas usando un bucle en lugar de escribir cada una de ellas por separado. Hice esta matriz para almacenar la información de mis páginas.

 const pages = [ { title: "Translate", url: "/translate", component: TranslatePage }, { title: "Study", url: "/study", component: StudyPage }, { title: "About", url: "/about", component: AboutPage }, { title: "Home", url: "/", component: HomePage }, { title: "Terms", url: "/study/terms", component: TermsPage }, ];

Para cada página, necesito renderizarla en este formato:

 <Route path="/study" exact element={ <StudyPage getDocuments={getDocuments} collectionRef={collectionRef} docs={docs} /> } />

¿Cómo puedo representar cada página usando currentPage.component para escribir la parte del elemento del componente Route? Para cada componente en mi matriz de páginas, necesito obtener

 element={<ComponentReadFromPagesArray getDocuments={getDocuments} collectionRef={collectionRef} docs={docs} />}

pero no sé cómo extraer el componente de la matriz y luego pasarlo al elemento como su propio componente con accesorios

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

0

Si entiendo bien tu pregunta, sería así:

 const routes = pages.map(({component: Page, url: path}) => { const element = (<Page {...{collectionRef, docs, getDocuments}} />); return (<Route {...{element, exact: true, path}} />); });
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!