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

77
Vistas
How to transfer data from one file to another in reactjs

i have this array of objects, the thing that i am trying to do is to take the array from the file it's sitting in, and transfer it to another file where i can map the items. This is my code (the formatting and spacing is not on point) :

const Upload = () => {


    const photos = [
        {
            id: new Date().getMilliseconds().toString(),
            imagePath: "url..."
        },
    ];

    return (
    <>
       // Markup ....
    </>
    );
};

And i want to do something like this:

import photos from './COMPONENT_NAME';
const Func = () => {
    return (
      <> {photos.map((item) => <div> code... </div> )} </>
    );

Is there any way to do it?

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

0

You can simply export them.
First, move the list outside of the Upload function and then put export key before the declaration like so.

 export const photos = [
      {
          id: new Date().getMilliseconds().toString(),
          imagePath: "url..."
      },
  ];

const Upload = () => { 


    return (
    <>
       // Markup ....
    </>
    );
};

Then import them.

import { photos } from './COMPONENT_NAME';
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