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

160
Views
How to render between two elements in React?

Here's the original HTML:

<div class="chat">
    <div class="uploadArea">
        ...
    </div>
    <section class="title">
        ...
    </section>
    <div class="content">
        ...
    </div>
</div>

I want to render a component between the title and the content. How can I do that?

ReactDOM.render(Component, document.getElementsByClassName("chat")[0]);

wouldn't really work, right?

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

0

Create an element which you can use as the container for you react application. Insert the created element in the position you want, like in this example after the .title element.

Then use the created element in the ReactDOM.render call.

React 17 and below:

const reactContainer = document.createElement('div');
const target = document.querySelector('.chat .title');

target.after(reactContainer);

ReactDOM.render(Component, reactContainer);

React 18 and above:

const reactContainer = document.createElement('div');
const target = document.querySelector('.chat .title');

target.after(reactContainer);

const root = createRoot(reactContainer);
root.render(Component);
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!