question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any downsides to having DeckGL as child of ReactMapGL?

See original GitHub issue

Hello,

I have two questions that I’d like your thoughts on.

  1. Is there any downside to mounting the <DeckGL /> component as a child of the ReactMapGL component? In the documentation it shows the other way. This is my current setup and it’s working but I didn’t know if there were any downsides.
    <ReactMapGL
      touchAction="pan-y"
      onInteractionStateChange={this.updateInteractionState}
      attributionControl={false}
      controller={this._mapController}
      {...this.props.viewport}
      preventStyleDiffing
      reuseMaps
      width="100%"
      height="100%"
      onError={this._onReactMapGLError}
      getCursor={this.getCursor}
      interactiveLayerIds={this.props.interactiveLayerIds}
      mapStyle={this.props.mapStyleURI.length > 0 ? this.props.mapStyleURI : this.props.baseLayer}
      mapboxApiAccessToken={this.props.mapboxAccessToken}
      onLoad={this._onMapLoad}
      transformRequest={this._transformRequest}
      onViewportChange={this._onViewportChange}
      onClick={this._onClick}
    >
      <DeckGL viewState={this.props.viewport} getCursor={this._handleDeckGLCursor} {...this.props.deckProps} />
    </ReactMapGL>
    
  2. Is it ok to mount multiple <DeckGL> components in the same project? Would this be ok?
    <>
      <DeckGL layers={...} />
      <DeckGL layers={...} />
    </>
    

Thank you in advance for any thoughts on this!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
Pessimistresscommented, Aug 14, 2020

Using DeckGL as a child of ReactMapGL should work. In our docs we recommend StaticMap as a child of DeckGL because:

  • It is easier to use the stateful map controller that way (instead of callback + state update). Managing view states in your own app results in more React rerenders, and potential perf issues if not written properly.
  • It avoids creating two sets of pointer event managers, one in DeckGL and one in ReactMapGL.

As @kylebarron said, if your two DeckGL instances renders to the same region, it is more performant to use multiple views. Otherwise, rendering two DeckGL instances is fine. If you have more than two, say 5-6, the hardware/browser may not support so many active WebGL contexts at once.

1reaction
kylebarroncommented, Aug 14, 2020
  • When you have ReactMapGL as the child, you can use StaticMap, which is more performant
  • You can pass through map state to use Mapbox style components like the zoom in/out button
  • You could mount multiple DeckGL components but there’s almost never a reason to do that. You can use multiple views for a side by side setup
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using deck.gl with React
There are no performance advantages to this syntax but it can allow for a more consistent, React-like coding style.
Read more >
React, Mapbox, Deck.GL Scatterplot Layer: Data Not Updating
I am trying to create a React app that uses deck.gl on a Mapbox map, and I am having trouble updating the "data"...
Read more >
Popup - react-map-gl
A string indicating the part of the popup that should be positioned closest to the coordinate, set via longitude and latitude . If...
Read more >
Using Mapbox GL JS with React - LogRocket Blog
npm install react-map-gl-geocoder deck.gl. Once we have this all set up, let's create a new SearchableMap map with the code below:
Read more >
react map gl interactive layer ids rerender - You.com
deck.gl applications that render these components as children of DeckGL will stop working. I propose we move some of the current code to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found