Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Geocode component generates bunch of errors #56

Closed
alexsinfarosa opened this issue Oct 31, 2019 · 23 comments
Closed

Adding Geocode component generates bunch of errors #56

alexsinfarosa opened this issue Oct 31, 2019 · 23 comments

Comments

@alexsinfarosa
Copy link

The errors occur only when adding the Geocoder component.

import React from "react"

import "react-map-gl-geocoder/dist/mapbox-gl-geocoder.css"
import "mapbox-gl/dist/mapbox-gl.css"

import ReactMapGL from "react-map-gl"
import Geocoder from "react-map-gl-geocoder"


export default function StationMap() {
  const settings = {
    dragPan: true,
    dragRotate: true,
    scrollZoom: false,
    touchZoom: true,
    touchRotate: true,
    keyboard: true,
    doubleClickZoom: true,
    minZoom: 0,
    maxZoom: 20,
    minPitch: 0,
    maxPitch: 85,
  }

  const [viewport, setViewport] = React.useState({
    latitude: 42.444,
    longitude: -76.5019,
    zoom: 8,
    width: "100%",
    height: "100%",
  })


  const myMap = React.createRef()

  return (
   <ReactMapGL
     ref={myMap}
     {...viewport}
     {...settings}
     mapboxApiAccessToken={process.env.GATSBY_MAPBOX_TOKEN}
     mapStyle="mapbox://styles/mapbox/streets-v11"
     onViewportChange={viewport => setViewport(viewport)}
   >
     <Geocoder
       mapRef={myMap}
       mapboxApiAccessToken={process.env.GATSBY_MAPBOX_TOKEN}
     >
     </Geocoder>
</ReactMapGL>
  )
}

The log with the errors:

index.m.js:1 Uncaught TypeError: Cannot read property 'addControl' of null
    at i.e.initializeGeocoder (index.m.js:1)
    at i.o.componentDidMount (index.m.js:1)
    at i.<anonymous> (react-hot-loader.development.js:704)
    at commitLifeCycles (react-dom.development.js:21963)
    at commitLayoutEffects (react-dom.development.js:25287)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:467)
    at commitRootImpl (react-dom.development.js:25023)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at commitRoot (react-dom.development.js:24864)
    at finishSyncRender (react-dom.development.js:24250)
    at performSyncWorkOnRoot (react-dom.development.js:24222)
    at react-dom.development.js:12239
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushSyncCallbackQueueImpl (react-dom.development.js:12234)
    at flushSyncCallbackQueue (react-dom.development.js:12222)
    at flushPassiveEffectsImpl (react-dom.development.js:25367)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushPassiveEffects (react-dom.development.js:25304)
    at react-dom.development.js:25183
    at workLoop (scheduler.development.js:759)
    at flushWork (scheduler.development.js:714)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:219)
e.initializeGeocoder @ index.m.js:1
o.componentDidMount @ index.m.js:1
componentDidMount @ react-hot-loader.development.js:704
commitLifeCycles @ react-dom.development.js:21963
commitLayoutEffects @ react-dom.development.js:25287
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
commitRootImpl @ react-dom.development.js:25023
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
commitRoot @ react-dom.development.js:24864
finishSyncRender @ react-dom.development.js:24250
performSyncWorkOnRoot @ react-dom.development.js:24222
(anonymous) @ react-dom.development.js:12239
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushSyncCallbackQueueImpl @ react-dom.development.js:12234
flushSyncCallbackQueue @ react-dom.development.js:12222
flushPassiveEffectsImpl @ react-dom.development.js:25367
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushPassiveEffects @ react-dom.development.js:25304
(anonymous) @ react-dom.development.js:25183
workLoop @ scheduler.development.js:759
flushWork @ scheduler.development.js:714
performWorkUntilDeadline @ scheduler.development.js:219
index.m.js:1 Uncaught TypeError: Cannot read property 'remove' of undefined
    at Gt.off (index.m.js:1)
    at i.e.unsubscribeEvents (index.m.js:1)
    at i.e.removeGeocoder (index.m.js:1)
    at i.o.componentWillUnmount (index.m.js:1)
    at i.<anonymous> (react-hot-loader.development.js:704)
    at callComponentWillUnmountWithTimer (react-dom.development.js:21756)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:467)
    at safelyCallComponentWillUnmount (react-dom.development.js:21763)
    at commitUnmount (react-dom.development.js:22256)
    at commitNestedUnmounts (react-dom.development.js:22350)
    at unmountHostComponents (react-dom.development.js:22682)
    at commitDeletion (react-dom.development.js:22768)
    at commitMutationEffects (react-dom.development.js:25266)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:467)
    at commitRootImpl (react-dom.development.js:24989)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at commitRoot (react-dom.development.js:24864)
    at finishSyncRender (react-dom.development.js:24250)
    at performSyncWorkOnRoot (react-dom.development.js:24222)
    at react-dom.development.js:12239
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushSyncCallbackQueueImpl (react-dom.development.js:12234)
    at flushSyncCallbackQueue (react-dom.development.js:12222)
    at flushPassiveEffectsImpl (react-dom.development.js:25367)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushPassiveEffects (react-dom.development.js:25304)
    at react-dom.development.js:25183
    at workLoop (scheduler.development.js:759)
    at flushWork (scheduler.development.js:714)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:219)
off @ index.m.js:1
e.unsubscribeEvents @ index.m.js:1
e.removeGeocoder @ index.m.js:1
o.componentWillUnmount @ index.m.js:1
componentDidMount @ react-hot-loader.development.js:704
callComponentWillUnmountWithTimer @ react-dom.development.js:21756
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
safelyCallComponentWillUnmount @ react-dom.development.js:21763
commitUnmount @ react-dom.development.js:22256
commitNestedUnmounts @ react-dom.development.js:22350
unmountHostComponents @ react-dom.development.js:22682
commitDeletion @ react-dom.development.js:22768
commitMutationEffects @ react-dom.development.js:25266
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
commitRootImpl @ react-dom.development.js:24989
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
commitRoot @ react-dom.development.js:24864
finishSyncRender @ react-dom.development.js:24250
performSyncWorkOnRoot @ react-dom.development.js:24222
(anonymous) @ react-dom.development.js:12239
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushSyncCallbackQueueImpl @ react-dom.development.js:12234
flushSyncCallbackQueue @ react-dom.development.js:12222
flushPassiveEffectsImpl @ react-dom.development.js:25367
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushPassiveEffects @ react-dom.development.js:25304
(anonymous) @ react-dom.development.js:25183
workLoop @ scheduler.development.js:759
flushWork @ scheduler.development.js:714
performWorkUntilDeadline @ scheduler.development.js:219
Show 7 more frames
index.js:2177 The above error occurred in the <i> component:
    in i (at stationsMap.js:68)
    in div (created by Context.Consumer)
    in div (created by AutoSizer)
    in AutoSizer (created by StaticMap)
    in div (created by StaticMap)
    in StaticMap (created by InteractiveMap)
    in div (created by InteractiveMap)
    in InteractiveMap (at stationsMap.js:59)
    in div (at stationsMap.js:47)
    in div (at stationsMap.js:37)
    in StationMap (at pages/index.js:63)
    in div (at pages/index.js:62)
    in div (at pages/index.js:60)
    in section (at pages/index.js:59)
    in main (at layout.js:24)
    in Layout (at pages/index.js:15)
    in IndexPage (created by HotExportedIndexPage)
    in AppContainer (created by HotExportedIndexPage)
    in HotExportedIndexPage (created by PageRenderer)
    in PageRenderer (at json-store.js:93)
    in JSONStore (at root.js:51)
    in RouteHandler (at root.js:73)
    in div (created by FocusHandlerImpl)
    in FocusHandlerImpl (created by Context.Consumer)
    in FocusHandler (created by RouterImpl)
    in RouterImpl (created by Context.Consumer)
    in Location (created by Context.Consumer)
    in Router (created by EnsureResources)
    in ScrollContext (at root.js:64)
    in RouteUpdates (at root.js:63)
    in EnsureResources (at root.js:61)
    in LocationHandler (at root.js:119)
    in LocationProvider (created by Context.Consumer)
    in Location (at root.js:118)
    in Root (at root.js:126)
    in SessionCheck (at gatsby-browser.js:75)
    in _default (at app.js:67)

React will try to recreate this component tree from scratch using the error boundary you provided, AppContainer.
__stack_frame_overlay_proxy_console__ @ index.js:2177
r @ backend.js:6
logCapturedError @ react-dom.development.js:21703
logError @ react-dom.development.js:21740
callback @ react-dom.development.js:23144
callCallback @ react-dom.development.js:13863
commitUpdateEffects @ react-dom.development.js:13901
commitUpdateQueue @ react-dom.development.js:13889
commitLifeCycles @ react-dom.development.js:21997
commitLayoutEffects @ react-dom.development.js:25287
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
commitRootImpl @ react-dom.development.js:25023
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
commitRoot @ react-dom.development.js:24864
finishSyncRender @ react-dom.development.js:24250
performSyncWorkOnRoot @ react-dom.development.js:24222
(anonymous) @ react-dom.development.js:12239
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushSyncCallbackQueueImpl @ react-dom.development.js:12234
flushSyncCallbackQueue @ react-dom.development.js:12222
flushPassiveEffectsImpl @ react-dom.development.js:25367
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushPassiveEffects @ react-dom.development.js:25304
(anonymous) @ react-dom.development.js:25183
workLoop @ scheduler.development.js:759
flushWork @ scheduler.development.js:714
performWorkUntilDeadline @ scheduler.development.js:219
Show 2 more frames
index.js:2177 TypeError: Cannot read property 'addControl' of null
    at i.e.initializeGeocoder (index.m.js:1)
    at i.o.componentDidMount (index.m.js:1)
    at i.<anonymous> (react-hot-loader.development.js:704)
    at commitLifeCycles (react-dom.development.js:21963)
    at commitLayoutEffects (react-dom.development.js:25287)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:467)
    at commitRootImpl (react-dom.development.js:25023)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at commitRoot (react-dom.development.js:24864)
    at finishSyncRender (react-dom.development.js:24250)
    at performSyncWorkOnRoot (react-dom.development.js:24222)
    at react-dom.development.js:12239
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushSyncCallbackQueueImpl (react-dom.development.js:12234)
    at flushSyncCallbackQueue (react-dom.development.js:12222)
    at flushPassiveEffectsImpl (react-dom.development.js:25367)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushPassiveEffects (react-dom.development.js:25304)
    at react-dom.development.js:25183
    at workLoop (scheduler.development.js:759)
    at flushWork (scheduler.development.js:714)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:219) "
    in AppContainer (created by HotExportedIndexPage)
    in HotExportedIndexPage (created by PageRenderer)
    in PageRenderer (at json-store.js:93)
    in JSONStore (at root.js:51)
    in RouteHandler (at root.js:73)
    in EnsureResources (at root.js:61)
    in LocationHandler (at root.js:119)
    in LocationProvider (created by Context.Consumer)
    in Context.Consumer (created by Location)
    in Location (at root.js:118)
    in Root (at root.js:126)"
__stack_frame_overlay_proxy_console__ @ index.js:2177
r @ backend.js:6
error @ react-hot-loader.development.js:294
componentDidCatch @ react-hot-loader.development.js:2401
callback @ react-dom.development.js:23149
callCallback @ react-dom.development.js:13863
commitUpdateEffects @ react-dom.development.js:13901
commitUpdateQueue @ react-dom.development.js:13889
commitLifeCycles @ react-dom.development.js:21997
commitLayoutEffects @ react-dom.development.js:25287
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
commitRootImpl @ react-dom.development.js:25023
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
commitRoot @ react-dom.development.js:24864
finishSyncRender @ react-dom.development.js:24250
performSyncWorkOnRoot @ react-dom.development.js:24222
(anonymous) @ react-dom.development.js:12239
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushSyncCallbackQueueImpl @ react-dom.development.js:12234
flushSyncCallbackQueue @ react-dom.development.js:12222
flushPassiveEffectsImpl @ react-dom.development.js:25367
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushPassiveEffects @ react-dom.development.js:25304
(anonymous) @ react-dom.development.js:25183
workLoop @ scheduler.development.js:759
flushWork @ scheduler.development.js:714
performWorkUntilDeadline @ scheduler.development.js:219
Show 2 more frames
index.m.js:1 Uncaught TypeError: Cannot read property 'addControl' of null
    at i.e.initializeGeocoder (index.m.js:1)
    at i.o.componentDidMount (index.m.js:1)
    at i.<anonymous> (react-hot-loader.development.js:704)
    at commitLifeCycles (react-dom.development.js:21963)
    at commitLayoutEffects (react-dom.development.js:25287)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:467)
    at commitRootImpl (react-dom.development.js:25023)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at commitRoot (react-dom.development.js:24864)
    at finishSyncRender (react-dom.development.js:24250)
    at performSyncWorkOnRoot (react-dom.development.js:24222)
    at react-dom.development.js:12239
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushSyncCallbackQueueImpl (react-dom.development.js:12234)
    at flushSyncCallbackQueue (react-dom.development.js:12222)
    at flushPassiveEffectsImpl (react-dom.development.js:25367)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushPassiveEffects (react-dom.development.js:25304)
    at react-dom.development.js:25183
    at workLoop (scheduler.development.js:759)
    at flushWork (scheduler.development.js:714)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:219)
e.initializeGeocoder @ index.m.js:1
o.componentDidMount @ index.m.js:1
componentDidMount @ react-hot-loader.development.js:704
commitLifeCycles @ react-dom.development.js:21963
commitLayoutEffects @ react-dom.development.js:25287
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
commitRootImpl @ react-dom.development.js:25023
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
commitRoot @ react-dom.development.js:24864
finishSyncRender @ react-dom.development.js:24250
performSyncWorkOnRoot @ react-dom.development.js:24222
(anonymous) @ react-dom.development.js:12239
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushSyncCallbackQueueImpl @ react-dom.development.js:12234
flushSyncCallbackQueue @ react-dom.development.js:12222
flushPassiveEffectsImpl @ react-dom.development.js:25367
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushPassiveEffects @ react-dom.development.js:25304
(anonymous) @ react-dom.development.js:25183
workLoop @ scheduler.development.js:759
flushWork @ scheduler.development.js:714
performWorkUntilDeadline @ scheduler.development.js:219
index.js:2177 The above error occurred in the <AppContainer> component:
    in AppContainer (created by HotExportedIndexPage)
    in HotExportedIndexPage (created by PageRenderer)
    in PageRenderer (at json-store.js:93)
    in JSONStore (at root.js:51)
    in RouteHandler (at root.js:73)
    in div (created by FocusHandlerImpl)
    in FocusHandlerImpl (created by Context.Consumer)
    in FocusHandler (created by RouterImpl)
    in RouterImpl (created by Context.Consumer)
    in Location (created by Context.Consumer)
    in Router (created by EnsureResources)
    in ScrollContext (at root.js:64)
    in RouteUpdates (at root.js:63)
    in EnsureResources (at root.js:61)
    in LocationHandler (at root.js:119)
    in LocationProvider (created by Context.Consumer)
    in Location (at root.js:118)
    in Root (at root.js:126)
    in SessionCheck (at gatsby-browser.js:75)
    in _default (at app.js:67)

React will try to recreate this component tree from scratch using the error boundary you provided, LocationProvider.
__stack_frame_overlay_proxy_console__ @ index.js:2177
r @ backend.js:6
logCapturedError @ react-dom.development.js:21703
logError @ react-dom.development.js:21740
callback @ react-dom.development.js:23144
callCallback @ react-dom.development.js:13863
commitUpdateEffects @ react-dom.development.js:13901
commitUpdateQueue @ react-dom.development.js:13889
commitLifeCycles @ react-dom.development.js:21997
commitLayoutEffects @ react-dom.development.js:25287
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
commitRootImpl @ react-dom.development.js:25023
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
commitRoot @ react-dom.development.js:24864
finishSyncRender @ react-dom.development.js:24250
performSyncWorkOnRoot @ react-dom.development.js:24222
(anonymous) @ react-dom.development.js:12239
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushSyncCallbackQueueImpl @ react-dom.development.js:12234
flushSyncCallbackQueue @ react-dom.development.js:12222
flushPassiveEffectsImpl @ react-dom.development.js:25367
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushPassiveEffects @ react-dom.development.js:25304
(anonymous) @ react-dom.development.js:25183
workLoop @ scheduler.development.js:759
flushWork @ scheduler.development.js:714
performWorkUntilDeadline @ scheduler.development.js:219
Show 2 more frames
index.m.js:1 Uncaught TypeError: Cannot read property 'addControl' of null
    at i.e.initializeGeocoder (index.m.js:1)
    at i.o.componentDidMount (index.m.js:1)
    at i.<anonymous> (react-hot-loader.development.js:704)
    at commitLifeCycles (react-dom.development.js:21963)
    at commitLayoutEffects (react-dom.development.js:25287)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:467)
    at commitRootImpl (react-dom.development.js:25023)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at commitRoot (react-dom.development.js:24864)
    at finishSyncRender (react-dom.development.js:24250)
    at performSyncWorkOnRoot (react-dom.development.js:24222)
    at react-dom.development.js:12239
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushSyncCallbackQueueImpl (react-dom.development.js:12234)
    at flushSyncCallbackQueue (react-dom.development.js:12222)
    at flushPassiveEffectsImpl (react-dom.development.js:25367)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushPassiveEffects (react-dom.development.js:25304)
    at react-dom.development.js:25183
    at workLoop (scheduler.development.js:759)
    at flushWork (scheduler.development.js:714)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:219)
e.initializeGeocoder @ index.m.js:1
o.componentDidMount @ index.m.js:1
componentDidMount @ react-hot-loader.development.js:704
commitLifeCycles @ react-dom.development.js:21963
commitLayoutEffects @ react-dom.development.js:25287
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
commitRootImpl @ react-dom.development.js:25023
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
commitRoot @ react-dom.development.js:24864
finishSyncRender @ react-dom.development.js:24250
performSyncWorkOnRoot @ react-dom.development.js:24222
(anonymous) @ react-dom.development.js:12239
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushSyncCallbackQueueImpl @ react-dom.development.js:12234
flushSyncCallbackQueue @ react-dom.development.js:12222
flushPassiveEffectsImpl @ react-dom.development.js:25367
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushPassiveEffects @ react-dom.development.js:25304
(anonymous) @ react-dom.development.js:25183
workLoop @ scheduler.development.js:759
flushWork @ scheduler.development.js:714
performWorkUntilDeadline @ scheduler.development.js:219
index.js:2177 The above error occurred in the <LocationProvider> component:
    in LocationProvider (created by Context.Consumer)
    in Location (at root.js:118)
    in Root (at root.js:126)
    in SessionCheck (at gatsby-browser.js:75)
    in _default (at app.js:67)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
__stack_frame_overlay_proxy_console__ @ index.js:2177
r @ backend.js:6
logCapturedError @ react-dom.development.js:21703
logError @ react-dom.development.js:21740
update.callback @ react-dom.development.js:23108
callCallback @ react-dom.development.js:13863
commitUpdateEffects @ react-dom.development.js:13901
commitUpdateQueue @ react-dom.development.js:13889
commitLifeCycles @ react-dom.development.js:22022
commitLayoutEffects @ react-dom.development.js:25287
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
commitRootImpl @ react-dom.development.js:25023
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
commitRoot @ react-dom.development.js:24864
finishSyncRender @ react-dom.development.js:24250
performSyncWorkOnRoot @ react-dom.development.js:24222
(anonymous) @ react-dom.development.js:12239
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushSyncCallbackQueueImpl @ react-dom.development.js:12234
flushSyncCallbackQueue @ react-dom.development.js:12222
flushPassiveEffectsImpl @ react-dom.development.js:25367
unstable_runWithPriority @ scheduler.development.js:815
runWithPriority$2 @ react-dom.development.js:12189
flushPassiveEffects @ react-dom.development.js:25304
(anonymous) @ react-dom.development.js:25183
workLoop @ scheduler.development.js:759
flushWork @ scheduler.development.js:714
performWorkUntilDeadline @ scheduler.development.js:219
Show 2 more frames
index.m.js:1 Uncaught TypeError: Cannot read property 'addControl' of null
    at i.e.initializeGeocoder (index.m.js:1)
    at i.o.componentDidMount (index.m.js:1)
    at i.<anonymous> (react-hot-loader.development.js:704)
    at commitLifeCycles (react-dom.development.js:21963)
    at commitLayoutEffects (react-dom.development.js:25287)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:467)
    at commitRootImpl (react-dom.development.js:25023)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at commitRoot (react-dom.development.js:24864)
    at finishSyncRender (react-dom.development.js:24250)
    at performSyncWorkOnRoot (react-dom.development.js:24222)
    at react-dom.development.js:12239
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushSyncCallbackQueueImpl (react-dom.development.js:12234)
    at flushSyncCallbackQueue (react-dom.development.js:12222)
    at flushPassiveEffectsImpl (react-dom.development.js:25367)
    at unstable_runWithPriority (scheduler.development.js:815)
    at runWithPriority$2 (react-dom.development.js:12189)
    at flushPassiveEffects (react-dom.development.js:25304)
    at react-dom.development.js:25183
    at workLoop (scheduler.development.js:759)
    at flushWork (scheduler.development.js:714)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:219)
@SamSamskies
Copy link
Owner

I've never tried using this component using a functional component and hooks, so maybe there's an issue with that. The geocoder is not initialized until after the Geocoder component is mounted. The mapbox map instance should exist by that point, but in your case it's not.

Please provide version numbers of react, react-map-gl, and react-map-gl-geocoder. Also, it helps a lot if you provide a Code Sandbox that demonstrates the issue.

If you want a quick fix, I'm pretty sure you could convert this to a good ol class component and it would work.

@SamSamskies
Copy link
Owner

One other thing to try is React.useRef instead of React.createRef https://stackoverflow.com/questions/54620698/whats-the-difference-between-useref-and-createref. createRef creates a new ref on every render.

@alexsinfarosa
Copy link
Author

I switched to React.useRef instead and it works, no need to convert to a class component. Thanks a lot!

@imran-5
Copy link

imran-5 commented Mar 3, 2020

I am using the useRef() but still facing issue with.
image

@SamSamskies
Copy link
Owner

Hi @I1mran, is it possible for you to share you component code? It will be hard to debug without seeing that.

Contents should look something like this...

  const mapRef = React.useRef()

  return (
   <ReactMapGL
     ref={mapRef}
     {...viewport}
     width="100%"
     height="100%"
     onViewportChange={handleViewportChange}
     mapboxApiAccessToken={MAPBOX_TOKEN}
   >
     <Geocoder
       mapRef={mapRef}
       onViewportChange={handleViewportChange}
       mapboxApiAccessToken={MAPBOX_TOKEN}
     >
     </Geocoder>
</ReactMapGL>
  )

Also, make sure that the prop you are using on Geocoder is mapRef and not ref. It's passing ReactMapGL's ref down to Geocoder cause Geocoder needs that to get a handle to the underlying Mapbox GL Map object.

@imran-5
Copy link

imran-5 commented Mar 3, 2020

after some changes with the code, now seeing the issue of blank screen without mapbox gl instance.

<MapGL
                mapRef={_mapRef}
                {...viewport}
                width="100%"
                height="100%"
                mapStyle="mapbox://styles/mapbox/satellite-v9"
                mapboxApiAccessToken={TOKEN}
                onViewportChange={_updateViewport}
            >
                <Geocoder
                    mapRef={_mapRef}
                    onViewportChange={_handleGeocoderViewportChange}
                    mapboxApiAccessToken={TOKEN}
                >
                </Geocoder>
</MapGL>

@SamSamskies
Copy link
Owner

On your MapGL component, you should be using the ref prop because you want the actual ref to that component instance. MapGL component doesn't have a prop called mapRef.

@imran-5
Copy link

imran-5 commented Mar 3, 2020

changed to

ref={mapRef}

Same restuls.

@scottbasgaard
Copy link

Same issue here, Can this be used with DeckGL and StaticMap components?

@SamSamskies
Copy link
Owner

SamSamskies commented Mar 4, 2020

What version number of react-map-gl are you using? I haven't tried using this component with v5 of react-map-gl yet. It's possible that they made breaking changes to their API which would cause issues for this component.

The ref that needs to be passed to the mapRef prop of this component is required to be a ref to an instance of the default export of react-map-gl. It won't work if the ref is for an instance of the default export of deck.gl. I think an instance of StaticMap would work, but I haven't tried it.

If you include a Code Sandbox demonstrating the issue it would be much easier for me to help debug.

@SamSamskies SamSamskies reopened this Mar 4, 2020
@Maruthasalam
Copy link

In functional component use useRef instead of createRef it will work

@SamSamskies
Copy link
Owner

Finally got around to making a Code Sandbox example of using react-map-gl-geocoder in a functional component using hooks. https://codesandbox.io/s/react-map-gl-geocoder-v2-example-096iq

@chiho13
Copy link

chiho13 commented May 17, 2020

it's not working with next.js

@SamSamskies
Copy link
Owner

SamSamskies commented May 17, 2020

Hi @chiho13, this is a known issue that I haven't got around to fixing. A workaround is described here #36 (comment).

@chiho13
Copy link

chiho13 commented May 17, 2020

@SamSamskies i used dynamic import in next.js but can't replicated the results in the codesandbox

@chiho13
Copy link

chiho13 commented May 18, 2020

@SamSamskies i got it working, but i had to force override .mapboxgl-ctrl css class to display block important! to show the input box

@Marius-Adam
Copy link

Hi @SamSamskies. Been having the same problem as @I1mran. When I checked out your CodeSanbox I am getting a SyntaxError
Invalid left-hand side expression in prefix operation

@SamSamskies
Copy link
Owner

Hi @Marius-Adam, currently all Code Sandboxes with deck.gl seem to be having that issue. I fixed the example by removing deck.gl. I had fixed it earlier this week, but I guess my changes didn't save. Try it now https://codesandbox.io/s/l7p179qr6m.

@vlady-yakymenko
Copy link

Hi @SamSamskies, I am using react-map-gl and react-map-gl-geocoder in Electron App(https://github.com/electron-react-boilerplate/electron-react-boilerplate), it works well in dev mode, but on production mode, it is showing errors like
image
if you can let me know any thought on this, it would be great! Thanks
I just followed this one:https://codesandbox.io/s/l7p179qr6m, working well on dev mode.

@David05500
Copy link

it's not working with next.js

any help since?

@georgioslymperisdjakne
Copy link

georgioslymperisdjakne commented Oct 11, 2022

I found the solution:

<MapGL
    ref={mapRef}
    {...viewport}
    width="100%"
    height="100%"
    onViewportChange={handleViewportChange}
    mapboxApiAccessToken={MAPBOX_TOKEN}
  >
      {mapRef.current ? (
        <Geocoder
          mapRef={mapRef}
          onViewportChange={handleGeocoderViewportChange}
          mapboxApiAccessToken={MAPBOX_TOKEN}
          position="top-left"
        />
      ) : null}
</MapGL>

I tried with @mapbox/mapbox-gl-geocoder and I realized that I was getting the same error until I added the condition.
It requires some ms to update the mapRef.

@georgioslymperisdjakne
Copy link

react-map-gl-geocoder doesn't use react-map-gl version 7. According to https://visgl.github.io/react-map-gl/docs/upgrade-guide the LinearInterpolator and FlyToInterpolator are removed. Use map.easeTo() and map.flyTo(). You have to use older versions of react-map-gl.

@mclars
Copy link

mclars commented Oct 12, 2022

react-map-gl-geocoder doesn't use react-map-gl version 7. According to https://visgl.github.io/react-map-gl/docs/upgrade-guide the LinearInterpolator and FlyToInterpolator are removed. Use map.easeTo() and map.flyTo(). You have to use older versions of react-map-gl.

Yep just got to the same point with errors of these missing, too bad =(

However, this example works; https://visgl.github.io/react-map-gl/examples/geocoder . Just don't forget to add the css file they have in the index.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests