Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

286
Visualizações
React: How to replace a JSX tag within a function component?

I'm trying to modify a child component existing within a function component.

Let's say this is the original Table function component I would like to render in my own CustomizedTable function component. Since the Table function component is beautifully designed, I don't want to modify the entire function or structure. What I hope to achieve is to customize and replace the existing Body component

const Table = (props) => {
  return (
    <Context props={props}>
      <Container className={props.className} style={props.style}>
          <Header />
          <Body
              ColumnComponents={ColumnData}
              RowComponents={RowData}
          />
          <Footer />
      </Container>
    </Context>
  );
});

How do I find and replace the <Body/> component with <CustomizedBody> that is nested within the Table function component? Is there a way to modify it without touching the existing <Body>?

   import { Table } from './Table';


   const CustomizedBody = (props) => {
   return (
      <Body>
      // Body Add Ons
      </Body>
   )}

   export const CustomizedTable = (props) => { 
    
   return (
       <Table Body={<CustomizedBody>}>
       </Table>
   )}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As you are passing it as a props you can use it as props.children in the main component.

React recommends using composition pattern over the inheritance. You can read further more here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda