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

287
Views
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 answers
Answer question

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 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!