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

255
Vistas
How can I import my objects file in react

I have an .js file where I have my books as bellow:

export const booksData = [
{
    id: "1",
    title: "1491",
    description: "A fantastic historical book",
    genre: 'Historical',
    image: "https://shop.radical-guide.com/wp-content/uploads/2020/06/1491-Front.jpg"
},

How can I import and display these books dynamically in my react application?

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

0

import { booksData } from "path/to/file.js"

You don't really need to pass it as a prop. Only if you are using a component, then yes, you should, eg:

<Component books={booksData} />

Then, in the Component function you pass it as a prop.

function Component(props){
    return (
     <>
         {
           props.books.map(book => {
            return(
           <h1>{book.title}</h1>
         )})}
    </>
)}

If not, you can directly import to the component that object(not recommended)

import { booksData } from "path/to/file.js"

And simply:

function Component(){

    return (
     <>
         {
           booksData.map(book => {
            return(
           <h1>{book.title}</h1>
         )})}
    </>
)}
about 4 years ago · Juan Pablo Isaza Denunciar

0

// First of All You Need to import your .js file like that

import booksData from '/path/to/file.js'

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