Conversation
usePropBinding assigned every bound prop on mount, including the ones the consumer left out, so each custom element received a burst of `undefined` writes. On the Maps API that clobbers defaults the element set up for itself (the class of visgl#867) and, for deprecated or channel-gated properties such as `coordinates`, `innerCoordinates`, `outerCoordinates`, and `autofitsCamera` on the 3D elements, logs a console warning for a prop the consumer never wrote, once per element. A prop is now written only once it has a value; after that, a later `undefined` still clears it, and a fresh object starts untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
usePropBindingassigns every bound prop as soon as the element exists, including the props the consumer left out, so each custom element receives a burst ofundefinedwrites on mount. Two effects of that on the Maps API:<Polyline3D>logsautofitsCamera is not supported in this versionandThe coordinates property is deprecated, and every<Polygon3D>addsinnerCoordinatesandouterCoordinates, once per element, even when the app only ever passedpathandinnerPaths.Change
A prop is written only once it has a value. After that, a later
undefinedstill clears it (removing a prop keeps working), and a fresh object starts untouched even if the hook wrote to a previous one.This is the general form of the guard #1066 adds inside
useAdvancedMarkerAnchoring; it covers everyusePropBindingcall site in the 3D components,Marker3D, andPopover.Tests
src/hooks/__tests__/use-prop-binding.test.tsx: unprovided prop never written (no own property), provided values includingnullwritten, value-then-undefinedclears, and a new object is left untouched.npm test: 23 suites / 194 tests pass,tsc --project tsconfig.test.json, eslint and prettier clean.