Skip to content

fix(core): explicitly undefined Deck props fall back to defaults - #10906

Merged
chrisgervang merged 5 commits into
visgl:masterfrom
madcow95:fix/undefined-props-use-defaults
Nov 18, 2026
Merged

chrisgervang merged 5 commits into
visgl:masterfrom
madcow95:fix/undefined-props-use-defaults

Conversation

@madcow95

Copy link
Copy Markdown
Contributor

Closes #10904

Change List

  • Deck: explicitly undefined props fall back to their defaults
  • Applies in constructor and setProps
  • Unit tests

@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Deck now replaces explicitly undefined props with their defaults in both the constructor and setProps.

  • Deck props with explicit undefined values now use their defaults.

Reviews (5) · Last reviewed commit: "Merge branch 'master' into fix/undefined..." · Reviewed by Greptile

Comment thread modules/core/src/lib/deck.ts Resolved
@chrisgervang chrisgervang mentioned this pull request Oct 29, 2026
29 of 30 tasks

@chrisgervang chrisgervang left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audited every Deck prop against an explicit undefined. 18 of the 48 behave differently from their default today, and none of those differences is intended or documented: they're crashes (the unguarded callbacks, plus getCursor and effects), silent breakage (pickAsync: undefined turns off picking), or undefined falling into a branch written for null or for a missing key. So resolving undefined to the default for every prop is the right fix.

Because a few props change behavior for apps that pass undefined today, this needs an entry in the v10 upgrade guide. Could you add the section below to docs/upgrade-guide.md, at the end of "Upgrading to v10", just before ## Upgrading to v9.4? I'll approve once it's in.

### Deck props set to `undefined`

A [`Deck`](./api-reference/core/deck.md) prop set to `undefined`, in the constructor or in
`setProps`, now uses its default value, the same as leaving the prop out. Previously an
explicit `undefined` replaced the default. For some props this threw an error or stopped
rendering, such as a callback like `onAfterRender: debug ? callback : undefined`.

A few props behaved differently with `undefined`. To keep that behavior, pass these instead:

| Prop | `undefined` now | To get the previous behavior |
| --- | --- | --- |
| `width`, `height` | `'100%'` | `null`, to leave the canvas size to your CSS |
| `onError` | Logs the error (the default) | `null`, to ignore errors |
| `debug` | `false` | `true`, to enable GPU debug mode |
| `layers`, `widgets` in `setProps` | Removes them | Leave the prop out of `setProps` to keep the current ones |
| `useDevicePixels` | `true` | `false`, to render one canvas pixel per CSS pixel |
| `touchAction` | `'none'` | The `touch-action` value you want, such as `'manipulation'` |

`null` is unchanged. Props without a default are also unchanged.

Optional, not blocking:

  • key in defaultProps also matches inherited keys such as toString. Object.prototype.hasOwnProperty.call(defaultProps, key) is more precise.
  • Tests for setProps({layers: undefined}) clearing the layers, and for effects: undefined initializing without throwing.

Generated by Claude Code

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 84.406% (+0.005%) from 84.401% — madcow95:fix/undefined-props-use-defaults into visgl:master

@chrisgervang chrisgervang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having undefined reset a prop to its default value seems like the right choice. Probably should have done this a while ago, thanks for the PR!

Omitted keys still keep their previous value, which is still critical behavior for the imperative setProps API.

This change also simplifies the new react fiber we're developing

I'll merge this after the upgrade guide was added. Feel free to tweak the guide Claude posted! (I vetted it, but if something seems unclear feel free to tweak wording)

@chrisgervang
chrisgervang added this pull request to the merge queue Nov 18, 2026
Merged via the queue into visgl:master with commit 4844763 Nov 18, 2026
9 checks passed
chrisgervang pushed a commit that referenced this pull request Nov 21, 2026
Deck.setProps resets an explicit undefined to its default (#10906), so passing
device or _canvases as undefined hit the same problems as removing them. The
root leaves either out of setProps when it is undefined, as when it is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-visgl__deck.gl that referenced this pull request Nov 22, 2026
… at creation (visgl#11267)

* fix(react): reset removed props, and warn about props that only apply at creation

Replays visgl/deck.gl-community#1088 onto @deck.gl/react. visgl#10906 made Deck fall
back to the default for a prop passed as undefined, so the root only resets
props that a render removed, and passes undefined through.

- A prop the last configure had and this one doesn't is sent as its Deck
  default. layers, views, widgets and effects are left out of that spread, so
  views={undefined} can't clear views that a widget such as SplitterWidget set.
- An overlay that doesn't forward JSX views follows the same views rule with
  its views prop alone.
- In development builds, changing deviceProps, gl, debug, touchAction,
  eventRecognizerOptions or _typedArrayManagerProps after creation warns once
  per prop per root, with a link to the DeckGL docs.

The community PR's yarn patch isn't needed: deck.gl builds @deck.gl/core from
source, which includes visgl#10906. Its creation-only test runs in the jsdom react
project, where vi.stubEnv reaches process.env.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* fix(react): keep device and _canvases when they are removed

A live Deck can't take their defaults. Deck.setProps only swaps in a new
device, so sending null left Deck rendering with its device while its props
said null. _canvases chose single- or multi-canvas mode, and Deck.setProps
asserts that the mode never changes, so sending null threw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* fix(react): keep device and _canvases passed as undefined

Deck.setProps resets an explicit undefined to its default (visgl#10906), so passing
device or _canvases as undefined hit the same problems as removing them. The
root leaves either out of setProps when it is undefined, as when it is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* fix(react): don't use Object.hasOwn in the prop-reset helper

Safari 15.0-15.3 lack Object.hasOwn, so the second configure threw there.
getRemovedProps uses Object.prototype.hasOwnProperty.call, as visgl#11114 does, with
the same own-property semantics. A test runs two configures with Object.hasOwn
removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* test(react): check a removed callback, generated ids and a creation-only warning in one root

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

---------

Co-authored-by: Claude <[email protected]>
@chrisgervang chrisgervang mentioned this pull request Nov 24, 2026
29 tasks
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

Successfully merging this pull request may close these issues.

[Bug] Explicit undefined for a callback prop (e.g. onAfterRender) replaces the default and breaks rendering

3 participants