react-native-draggable-flatlist icon indicating copy to clipboard operation
react-native-draggable-flatlist copied to clipboard

TypeError: Cannot read properties of undefined (reading 'map')

Open perqa opened this issue 2 years ago • 2 comments

Description

ExceptionsManager.js:151 TypeError: Cannot read properties of undefined (reading 'map')

This error is located at:
    in function DraggableFlatListInner
    in file react-native-draggable-flatlist/src/components/DraggableFlatList.tsx

 const dataRef = useRef(props.data);
  const dataHasChanged =
    dataRef.current.map(keyExtractor).join("") !==
--> props.data.map(keyExtractor).join("");
  dataRef.current = props.data;

To Reproduce Call function DraggableFlatListInner with empty props argument.

Platform & Dependencies Platform: iOS Device: iPhone 12 Simulator

"dependencies": {
    "expo": "~47.0.8",
    "expo-status-bar": "~1.4.2",
    "react": "18.1.0",
    "react-native": "0.70.8",
    "react-native-design-system": "^2.0.3",
    "react-native-draggable-flatlist": "^4.0.0",
    "react-native-gesture-handler": "~2.8.0",
    "react-native-get-random-values": "^1.8.0",
    "react-native-reanimated": "~2.12.0",
    "uuid": "^9.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },

perqa avatar Sep 20 '23 07:09 perqa

Did you checked that the data you are passing is an array ?

vinodsnayvik avatar Oct 09 '23 07:10 vinodsnayvik

Hi, and thanks for the response. The reason I opened this ticket was just to suggest a more descriptive error message or a more defensive programming strategy. I mean if props.data is empty, it could be flagged, and there is no point in trying props.data.map.

perqa avatar Oct 09 '23 19:10 perqa