project_travel_advisor icon indicating copy to clipboard operation
project_travel_advisor copied to clipboard

issue in App.js

Open Ras443 opened this issue 3 years ago • 7 comments

error

Ras443 avatar Feb 02 '22 05:02 Ras443

use optional chaining on your data array

andyriles avatar Feb 08 '22 09:02 andyriles

Can you eloborate that?

Ras443 avatar Feb 11 '22 11:02 Ras443

Rather than data.filter, do data?.filter. Sometimes your internet might be slow, so data which you're fetching might not arrive when immediately. So when you run data.filter, since data would be currently empty, you can't filter an empty or nonexistent array, so it would throw an error. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

andyriles avatar Feb 11 '22 11:02 andyriles

go and checkout i did it

abhijain2003 avatar Mar 03 '22 09:03 abhijain2003

Rather than data.filter, do data?.filter. Sometimes your internet might be slow, so data which you're fetching might not arrive when immediately. So when you run data.filter, since data would be currently empty, you can't filter an empty or nonexistent array, so it would throw an error. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

still I was facing same issue, can u help me to fix it

16030IT028 avatar Jul 11 '22 13:07 16030IT028

go and checkout i did it

still I was facing same issue, can u help me to fix it

16030IT028 avatar Jul 11 '22 13:07 16030IT028

Hello Sire Can u help me to fix this problem?

st.js:12 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length')

` .then((data) => setWeatherData(data)); 42 | getPlacesData(type, bounds.sw, bounds.ne) 43 | .then((data) => {

44 | setPlaces(data?.filter((place) => place.name && place.num_reviews > 0)); | ^ 45 | setFilteredPlaces([]); 46 | setRating(''); 47 | setIsLoading(false);`

LorsHim66 avatar Apr 21 '23 17:04 LorsHim66