Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
Convert const array in function React

How to transform the "const itemsProject" below into a "function ItemsProject" with the same return?

function onClick(e, item) {}

const itemsProject = [
 {
  name: 'companies',
  label: translate('sidebarProjectCompanies'),
  Icon: CompanyIcon,
  path: '/project/:id/companies',
  onClick,
 }
 {
  name: 'currencies',
  label: translate('sidebarProjectCurrencies'),
  Icon: CurrencyIcon,
  path: '/project/:id/currencies',
  onClick,
 }
];

export default itemsProject;

I thank you for your help!

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

To get the data from a function and export it, you can use the following code:

function onClick(e, item) {}

function itemsProject() {
  return  [
   {
    name: 'companies',
    label: translate('sidebarProjectCompanies'),
    Icon: CompanyIcon,
    path: '/project/:id/companies',
    onClick,
   }
   {
    name: 'currencies',
    label: translate('sidebarProjectCurrencies'),
    Icon: CurrencyIcon,
    path: '/project/:id/currencies',
    onClick,
   }
 ]
};

export default itemsProject;

Use it in other files as:

import itemsProject from "/path/of/file";


itemsProject();

about 4 years ago · Juan Pablo Isaza Denunciar

0

Declare the function and return the same array.

function onClick(e, item) {}

function itemsProject() {

 return [
    {
       name: 'companies',
       label: translate('sidebarProjectCompanies'),
       Icon: CompanyIcon,
       path: '/project/:id/companies',
       onClick,
     }
     {
       name: 'currencies',
       label: translate('sidebarProjectCurrencies'),
       Icon: CurrencyIcon,
       path: '/project/:id/currencies',
       onClick,
     }
   ];
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda