Repository navigation
fix(core): keep the default view and widget id on a prototype - #11114
Conversation
Like layer props, `View` and `Widget` now keep their default `id` on the props prototype, so `Object.hasOwn(props, 'id')` tells a passed id from the default while `props.id` still reads the resolved id. - `makeViewport` sets `id` explicitly, since spreading props drops it - `View#equals` compares resolved ids, so an implicit and an explicit default id stay equal For #11113 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
[Medium impact] The PR appears safe to merge. SummaryMoves default view and widget IDs onto the props prototype so wrappers can distinguish defaults from explicit IDs.
Reviews (4) · Last reviewed commit: "fix(core): use hasOwnProperty instead of..." · Reviewed by Greptile |
Needs visgl/deck.gl#11114, which keeps the default view and widget id on the props prototype. A layer, view or widget now has no id exactly when Object.hasOwn(props, 'id') is false, so an explicit id equal to the class default, such as new MapView({id: 'MapView'}), is never renamed. deck.gl effects take no id, so only an effect a component built gets an id from its path; a raw <deckEffect> keeps its id. Until deck.gl releases #11114, a temporary yarn patch applies it to @deck.gl/[email protected]. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ffa20c3. Configure here.
…ned id The constructor drops an undefined id so the default on the props prototype shows through, but setProps assigned it as an own undefined. Widgets that reapply props, such as TooltipWidget, then had props.id undefined while id kept the default. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
…xcept View#equals and CustomProjectionView#equals give both sides their resolved id and compare with deepEqual, so the new deepEqualExcept helper is removed. The spread copies only own props, and adding the id back gives both objects the same keys, so equality is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Safari 15.0-15.3 lack Object.hasOwn, so the second configure threw there. getRemovedProps uses Object.prototype.hasOwnProperty.call, as #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
Takes master's #11114 (squash-merged) for the files this branch stacked on, keeps this PR's own change, and extends it to setProps: since #11114, setProps treats an undefined id as the class default, and it now does so for any falsy id. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
…React tree (#11271) For #11036 Replays visgl/deck.gl-community#1077 onto @deck.gl/react, now that #11114 keeps the default view and widget id on the props prototype. - reconciler/element-ids.ts (new): path-based ids and a dev-only duplicate-id warning - shared/generated-effect-id.ts (new): marks effects that a component built - reconciler/config.ts: stores each element's path; hidden clones keep it - reconciler/utils.ts: prop entries replace JSX elements by final id - wrappers/factories.tsx: effect components mark their effect - Removes the dead `needs a stable id` warning - Unit tests, including fast-check property tests of the id format
… 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]>
#11303) For #11113 - View, Widget: default id lives on the props prototype - View#makeViewport: set id explicitly, so #3259 can't return - View#equals: compare resolved ids, so new MapView() still equals new MapView({id: 'MapView'}) - Widget: {id: undefined} falls back to the default id, in the constructor and setProps - Add createPropsWithDefaultId util, shared by View and Widget - Unit tests (cherry picked from commit 17085f1) Backport to 9.4: drops the CustomProjectionView hunks; that view is not on 9.4.
|
Released in deck.gl 9.4.2, as #11303 on 9.4. |

For #11113
Background
ViewandWidgetwrite their defaultidintoprops, so code that wraps deck.gl can't tellnew MapView({id: 'MapView'})fromnew MapView(). Layers already keep the defaultidon the props prototype, soObject.hasOwn(layer.props, 'id')works for them.Change List
View,Widget: defaultidlives on the props prototypeView#makeViewport: setsidexplicitly, so Function passed as child of DeckGL react component never called #3259 can't returnCustomProjectionView#makeViewport: setsidexplicitlyView#equals,CustomProjectionView#equals: compare resolved idsnew MapView()still equalsnew MapView({id: 'MapView'}), so nothing rebuildsWidget:{id: undefined}falls back to the default id, in the constructor andsetPropscreatePropsWithDefaultIdutil, shared byViewandWidgetVerified with
yarn lintand theheadlesstests forcore,widgets,react,mapboxandmaplibre.Generated by Claude Code
Note
Low Risk
Refactors default property assignment for views and widgets with no breaking changes to public APIs and extensive test coverage.
Overview
Stores default
idvalues on the prototype ofpropsforViewandWidgetinstances instead of as own properties. This allows consumers and wrapper libraries to distinguish user-provided IDs from class defaults viaObject.hasOwn(props, 'id').The new helper
createPropsWithDefaultIdestablishes prototype-based default IDs during instantiation and updates. To prevent regression when spreading props,makeViewportinViewandCustomProjectionViewnow setsidexplicitly, and equality comparisons evaluate resolved IDs.Reviewed by Cursor Bugbot for commit 9875293. Bugbot is set up for automated code reviews on this repo. Configure here.