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

234
Views
How to call a Array in React. it return Error not json but array

when i call a array its return error in console.log().below my code is.i create memesData.js which contain array about the data and i want to call it from meme.js but when i call it give me some error in console.

'''' 
 import React from "react";
import memesData from "./memesData";
export default function Meme() {
 function getMemeImage() {
const memesArray = memesData.data.memes;
const randomNumber = Math.floor(Math.random() * memesArray.length);
const url = memesArray[randomNumber].url;
console.log(memesData.data.memes[0].url);
   }
 return (
  <main>
  <div className="form">
    <input type="text" placeholder="Top text" className="form--input" />
    <input type="text" placeholder="Bottom text" className="form--input" />
    <button className="form--button" onClick={getMemeImage}>
      Get a new meme image 
        </button>
       </div>
    </main>
   )
   }
'''

'''Uncaught TypeError: Cannot read properties of undefined (reading 'memes')
at getMemeImage (Meme.js:5:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)'''
about 4 years ago · Juan Pablo Isaza
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!