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

128
Views
How to render a generated component template in React?

Suppose i have a Parent and Child component in client side, server side returns a template string like below:

<Parent name="parent"><Child>i am child</Child></Parent>

now i need to show that inside the container in client side

<div id="container">{__templateplaceholder}</div>

Does anybody know how could i render the Parent and Child component in that placeholder area? thank you.

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

0

You can directly use your template string inside the tag but make sure to re render the page when the backend returns the data You can use React.useState() function to set the template string value returned from the backend

const [templateString , setTemplateString] = React.useState('');

wherever you recieve the data from backend in your react code add this this line will rerender the page after updating the value of template string so that it renders properly on the client side

setTemplateString(template_string_recieved_from_backend) 

And React Function Should Look like

const App = () => {
 return (

    <div id = "container"   dangerouslySetInnerHTML={{ __html: templateString 
      }}>
       

    </div>

 )
}
export default App;
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!