Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Deck.gl breaks the React Three Fiber reconciler due to function prototype pollution #9206

Open
7 tasks
marsy-invests opened this issue Oct 10, 2024 · 0 comments · May be fixed by #9207
Open
7 tasks
Labels

Comments

@marsy-invests
Copy link

Description

As soon as a deck.gl layer is created in an application that uses react-three-fiber (r3f), the r3f components stop responding to events. The reason is that create-props.ts is adding _mergedDefaultProps to the global function prototype, so all functions in the VM instance have that property in their prototype. That breaks the r3f reconciler's ability to determine that an event handler function has changed, so event handlers don't get replaced in the underlying three.js objects during renders when state changes.

Flavors

  • Script tag
  • React
  • Python/Jupyter notebook
  • MapboxOverlay
  • GoogleMapsOverlay
  • CartoLayer
  • ArcGIS

Expected Behavior

react-three-fiber and deck.gl should be able to co-exist in an application. I suspect that _mergedDefaultProps does not need to walk the entire prototype chain and add props all the way up to the root function prototype. and should probably only add props to the prototypes of components. I have a simple proposed change (PR to follow) that prevents deck.gl from breaking r3f applications and doesn't appear to break any existing deck.gl functionality.

Steps to Reproduce

Create a r3f application with event handlers that reference component state that changes. Create a deck.gl layer (don't have to add it to a map, just new it up), and observe that the r3f component event handlers no longer update as the state changes.

Environment

  • Framework version: 9.0.30
  • Browser: all
  • OS: MacOS

Logs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant