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

136
Views
Dynamic component render from dynamic list

There is the main(Template.js) page, in which data is fetched from API, using this data the List (from material-ui) is formed by renderTemplatesList function. How can I handle list element onClick event and change the h1 content?

//Template.js
export default function Template() {
  const [data, setData] = useState([]);

  useEffect(() => {
    //get data from backend...
  }, []);

  const templateData = renderTemplatesList(data);
  return (
    <div>
      <List>{templateData}</List>
    </div>
    <div>
      <h1>{/* Selected list item params */}</h1>
    </div>
  );
}
export const renderTemplatesList = (items) => {
  let templates = null;
  if (items !== undefined && items !== null && items.length !== 0) {
    templates = items.map((template) => (
      <ListItem>
        <ListItemButton>
          <ListItemText primary={template.name} />
        </ListItemButton>
      </ListItem>
    ));
  }
  return templates;
};
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!