Repository navigation
fix(core): explicitly undefined Deck props fall back to defaults - #10906
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
[Medium impact] The PR appears safe to merge; no new actionable issues were found. Summary
Reviews (5) · Last reviewed commit: "Merge branch 'master' into fix/undefined..." · Reviewed by Greptile |
There was a problem hiding this comment.
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 defaultPropsalso matches inherited keys such astoString.Object.prototype.hasOwnProperty.call(defaultProps, key)is more precise.- Tests for
setProps({layers: undefined})clearing the layers, and foreffects: undefinedinitializing without throwing.
Generated by Claude Code
chrisgervang
left a comment
There was a problem hiding this comment.
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)
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
… 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]>
Closes #10904
Change List
Deck: explicitlyundefinedprops fall back to their defaultssetProps