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

126
Views
How to store React component in object

I have an object of all apps:

 export const allApps: appInterface[] = [
  {
    id: uuidv4(),
    name: "Minesweeper",
    icon: minesweeperIcon,
    disabled: false,
  },
];

I want to add component property to each object like this:

 export const allApps: appInterface[] = [
  {
    id: uuidv4(),
    name: "Minesweeper",
    icon: minesweeperIcon,
    disabled: false,
    component: Minesweeper, //It is imported as import Minesweeper from ../Components/Minesweeper";
  },
];

And then I want to display all components in App.js:

allApps.forEach((app)=>{
  <div>{app.component}<div> // for eg: <div><Minesweeper/></div>
});

Is this possible to do?

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

0

Try as below code it should work.

allApps.map((app)=>{
const { component: Component } = app;
  return <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!