bramus / react-native-maps-directions

Directions Component for `react-native-maps`
MIT License
1.25k stars 198 forks source link

undefined is not an object (evaluating 'waypoints.map') on version 1.7.6 #133

Open karimcambridge opened 4 years ago

karimcambridge commented 4 years ago

I am confident that I am on version 1.7.6.

undefined is not an object (evaluating 'waypoints.map')
* http://192.168.0.27:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:197816:32 in <unknown>
* [native code]:null in map
* http://192.168.0.27:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:197803:31 in fetchAndRenderRoute
* http://192.168.0.27:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:197879:33 in componentDidMount
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:17029:10 in commitLifeCycles
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:20002:23 in commitLayoutEffects
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:307:15 in invokeGuardedCallbackImpl
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:531:36 in invokeGuardedCallback
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19768:10 in commitRootImpl
* [native code]:null in commitRootImpl
- node_modules\scheduler\cjs\scheduler.development.js:643:23 in unstable_runWithPriority
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19590:4 in commitRoot
* [native code]:null in commitRoot
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18709:28 in runRootCallback
* [native code]:null in runRootCallback
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5642:32 in runWithPriority$argument_1
- node_modules\scheduler\cjs\scheduler.development.js:643:23 in unstable_runWithPriority
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5638:22 in flushSyncCallbackQueueImpl
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5627:28 in flushSyncCallbackQueue
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18556:30 in scheduleUpdateOnFiber
- node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:11484:17 in dispatchAction
* [native code]:null in dispatchAction
* components\Map\LocationItem.js:20:29 in _onPlaceSelected
- node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
- node_modules\regenerator-runtime\runtime.js:271:30 in invoke
- node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
- node_modules\regenerator-runtime\runtime.js:135:28 in invoke
- node_modules\regenerator-runtime\runtime.js:145:19 in Promise.resolve.then$argument_0
- node_modules\promise\setimmediate\core.js:37:14 in tryCallOne
- node_modules\promise\setimmediate\core.js:123:25 in setImmediate$argument_0
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:146:14 in _callTimer
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:194:17 in _callImmediatesPass
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:458:30 in callImmediates
* [native code]:null in callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:407:6 in __callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:143:6 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:142:17 in __guard$argument_0
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue

I cleared npm cache, also expo cache.

<MapViewDirection
      destination={destination}
      origin={origin}
      onReady={onReady}
      apikey={GOOGLE_API_KEY_PLACES}
      strokeWidth={3}
      strokeColor={getMapLineColor(authState.user.map_type)}
      optimizeWaypoints={true} // Billing?
      timePrecision={'now'}
    />
karimcambridge commented 4 years ago

Your tests probably included using all the properties.

https://github.com/bramus/react-native-maps-directions/blob/80c0ae52c7640ca0acfb8af95345014c6f624e94/src/MapViewDirections.js#L138 might be the issue, as I don't use splitWaypoints

Also check out https://github.com/bramus/react-native-maps-directions/blob/80c0ae52c7640ca0acfb8af95345014c6f624e94/src/MapViewDirections.js#L172

I found this out as adding waypoints={[]} as a prop fixed it.

bramus commented 4 years ago

Hmmz, I've tested with only setting origin and destination (and an apikey of course) and that worked fine.

The value of initialWaypoints is set to default to [] in case no waypoints are given, on line 81:

https://github.com/bramus/react-native-maps-directions/blob/80c0ae52c7640ca0acfb8af95345014c6f624e94/src/MapViewDirections.js#L81

What platform are you using? Perhaps it has something to do with the runtime being used … I've seen that happen before, where the local build – which uses using V8 – sported newer ECMAScript Language features than the runtimes on the devices.

karimcambridge commented 4 years ago
  "dependencies": {
    "@expo/vector-icons": "^10.0.6",
    "@react-native-community/slider": "^2.0.8",
    "@twotalltotems/react-native-otp-input": "^1.2.1",
    "axios": "^0.19.2",
    "expo": "^36.0.2",
    "expo-asset": "~8.0.0",
    "expo-cellular": "^2.0.0",
    "expo-constants": "~8.0.0",
    "expo-facebook": "^8.0.0",
    "expo-font": "^8.0.0",
    "expo-google-app-auth": "^8.0.1",
    "expo-linear-gradient": "~8.0.0",
    "expo-location": "~8.0.0",
    "expo-permissions": "~8.0.0",
    "expo-screen-orientation": "^1.0.0",
    "expo-sms": "^8.0.0",
    "react": "16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz",
    "react-native-country-picker-modal": "^1.10.0",
    "react-native-dotenv": "^0.2.0",
    "react-native-gesture-handler": "^1.6.0",
    "react-native-google-autocomplete": "^0.1.8",
    "react-native-maps": "^0.27.1",
    "react-native-maps-directions": "^1.7.6",
    "react-native-masked-text": "^1.13.0",
    "react-native-paper": "^3.6.0",
    "react-native-reanimated": "^1.7.0",
    "react-native-safe-area-context": "^0.7.3",
    "react-native-screens": "^1.0.0-alpha.23",
    "react-native-unimodules": "^0.7.0",
    "react-navigation": "^4.3.1",
    "react-navigation-drawer": "^1.4.0",
    "react-navigation-stack": "^1.9.3",
    "react-navigation-tabs": "^1.2.0",
    "reanimated-bottom-sheet": "^1.0.0-alpha.19",
    "socket.io-client": "^2.3.0",
    "styled-components": "^5.0.1"
  },

Using expo

I probably make use of up to ES9. I try to stay updated with my coding.

Hitesh2297 commented 4 years ago

https://github.com/bramus/react-native-maps-directions/blob/80c0ae52c7640ca0acfb8af95345014c6f624e94/src/MapViewDirections.js#L161 in waypoints.map() I am getting waypoints = null

I am using "react-native-maps-directions": "^1.8.0"