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') - AirBnb Clone Tutorial

Anyone know why I am getting the type error below? I am following along this tutorial (about 59 mins in): https://www.youtube.com/watch?v=G5mmrBkCaP8

Here is my code:

import React, { useState } from 'react';
import ReactMapGL from 'react-map-gl';
import { getCenter } from 'geolib';

function Map({ searchResults }) {

   const coordinates = searchResults.map((result) => ({ 
     longitude: result.long,
     latitude: result.lat,

   }));
// The latitude and longitude of the center of the coordinates
   const center = getCenter(coordinates);

   const [viewport, setViewport] = useState({
    width: "100%",
    height: "100%",
    latitude: center.latitude,
    longitude: center.longitude,
    zoom: 10,
});

  return ( 
  <ReactMapGL
  mapStyle='mapbox://styles/shesonanadventure/cl063x0yl000r15n4frjpm9in'
  mapboxAccessToken={process.env.mapbox_key}
  {...viewport}
  onViewportChange={(nextViewport) => setViewport(nextViewport)}
  ></ReactMapGL>
  );
}

export default Map;

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

0

SearchResults is undefined.

Do searchResults && searchResults.map

Also make sure you’re passing the prop

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!