[Feat] @deck.gl/react: should a <deckLayer> nested in a <deckView> render only in that view?

Open
#11,289 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Active
Tech stack
react, typescript

Research direction

This is a design discussion, not a scoped change: the issue explicitly says no change is planned and lists five open questions. Start by reading the @deck.gl/react renderer where the JSX tree is flattened into one layers list, plus the docs' layerFilter example, and compare with @deck.gl/react/legacy. Then read #9670 and the ViewLayout docs to see whether per-view layer lists could carry nested deckLayer elements; also inspect Deck._canvases and View.canvasId for how the generated filter composes with app filters. Done here means a decision on opt-in vs default, opt-out, nested-view ownership and filter precedence, not a patch.

Written by the indexing model from the issue text.

Description

feature

Moved from visgl/deck.gl-community#1036, now that the renderer is @deck.gl/react in deck.gl. Tracking: #10161.

Target Use Case

Should this render points only in the main view?

<DeckGL>
  <deckView view={new MapView({id: 'main'})}>
    <deckLayer layer={new ScatterplotLayer({id: 'points'})} />
  </deckView>
  <deckView view={new MapView({id: 'minimap', x: '75%', width: '25%', height: '25%'})}>
    <deckLayer layer={new PathLayer({id: 'routes'})} />
  </deckView>
</DeckGL>

The tree suggests it does. Today it doesn't: the renderer flattens the tree into one layers list, and deck.gl draws every layer in every view unless the app passes a layerFilter. The @deck.gl/react docs say so and show a layerFilter example. @deck.gl/react/legacy reads JSX layers only from the direct children of DeckGL.

Proposal

Open for discussion; no change is planned yet.

  • The original fiber renderer once generated a layerFilter from the tree. In the community issue, brandonjpierce noted it was kludgey and couldn't opt a layer out of filtering.
  • #9670 proposes per-view layer lists, new View({layers}) or a LayerGroup that views reference. If core supports either, a nested <deckLayer> could map onto it directly instead of the renderer building a layerFilter.
  • ViewLayout already compiles a declarative view tree. JSX layout elements could follow it, and view-scoped layers could extend that pattern.
  • Multi-canvas (Deck._canvases, View.canvasId) scopes layers to a canvas's views with a generated layerFilter. A tree-based rule has to compose with that and with the app's own layerFilter.

Open questions:

  1. Opt-in (a root prop) or the default? A default changes what existing trees render.
  2. How does a layer opt out, so it renders in every view?
  3. With nested views, does a layer belong to its nearest view only?
  4. With a layerFilter prop, AND the two, or let the app's filter win?
  5. Should this wait for the view and layout work in #9670?
Dominant language
TypeScript
Stars
14.8k
Forks
2.3k
Avg merge
1d 9h
Merged PRs (30d)
230

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from visgl/deck.gl

All issues in visgl/deck.gl

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.