Home > database >  Passing Array from a Separate React js file To a Component
Passing Array from a Separate React js file To a Component

Time:12-22

const CardData = [
    {
        imgsrc ={require('../../../pictures/yellow.jpg')},
      title = "Hello World",
      details = "Card Details",
    },

]

(method) require(: any): any Parsing error: Unexpected token (3:25)eslint

I am getting this error on image tag. I dont know how to pass images in an array like that.

CodePudding user response:

Thats not a valid syntax, I think you want to try:

const CardData = [
  {
    imgsrc: require("../../../pictures/yellow.jpg"),
    title: "Hello World",
    details: "Card Details",
  },
]
  • Related