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

164
Views
How you would go about rendering a component inside an existing DOM node (that could change over time)?

Ok, this question sounds weird, but hear me out:

I am ussing @uppy/react, and it offers some buttons to trigger cloud file provider uploads (Google Drive, DropBox, etc)

I can get those buttons with document.querySelector.

I want to render a custom component inside one of them, but I can't figure out how! I tried ReactDom's createPortal and render methods in a few different ways but none of them work.

I know this is very anti-pattern, but I haven't managed to talk my designer out of the idea yet...

Here is what I'm currently trying:

const GDriveToggle = () => {
  const el = document.querySelector('[data-cy="GoogleDrive"]');

  const node = document.createElement("div") // I have also tried React.createElement here

  useEffect(() => {
    if (el && node) {
      ReactDOM.createPortal(<div>Foo</div>, node); // I have also tried render() here
      el?.appendChild(node)

      console.log(el) // el has node inside of it
      console.log(node) // node has the foo text inside of it

      // but none show up inside the button on the page, I'm guessing it gets lost on any 
         // rerender?
    }
  }, [el, node]);

  return null;
};
about 4 years ago · Juan Pablo Isaza
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!