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

178
Views
TypeError: Cannot read properties of undefined (reading 'map'). Error being thrown when I am trying to map over an array of cryptocurrencies

I am making a page which displays all the cryptocurrencies in the format of a card but I am getting an error.

import { Card, Row, Col, Input } from 'antd'
import React from 'react'
import { Link } from 'react-router-dom'
import { useGetCryptosQuery } from '../services/CryptoApi'
import { useState } from 'react'
import millify from 'millify'

const Cryptocurrencies = () => {
    const {data : cryptoList, isFetching } = useGetCryptosQuery()
    const [cryptos,setCryptos] = useState(cryptoList?.data?.coins)
    
    
    console.log(cryptos)
    
    return (
        <div>
           <Row gutter = {[32,32]} className = "crypto-card-container">
                {cryptos.map((currency) => (
                        
                        <Col xs = {24} sm = {12} lg = {6} className = "crypto-card" key = {currency.id}>
                            <Link to = {'/crypto/${currency.id}'}>
                                <Card
                                title = {'${currency.rank}. ${currency.name}'}
                                extra = {<img className = "crypto-img" src = {currency.iconUrl}/>}
                                hoverable
                                >
                                <p>Price : {millify(currency.price)}</p>
                                <p>Market Cap : {millify(currency.marketCap)}</p>
                                <p>Daily Change : {millify(currency.change)}</p>
                                </Card>
                            </Link>
                        </Col>
                ))}
           </Row>
        </div>
    )
}

export default Cryptocurrencies
 

what is the error in my map function and the callback I have used?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could use

{!isFetching && cryptos.map((currency) => (
  ...
))}

or

{!isFetching ? <LoadingOrPlaceHolder> : cryptos.map((currency) => (
  ...
))}

about 4 years ago · Juan Pablo Isaza Report
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!