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

Avoid adding props to global function prototype. Doing so breaks the react-three-fiber reconciler #9207

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion modules/core/src/lifecycle/create-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ASYNC_DEFAULTS_SYMBOL
} from './constants';
import {StatefulComponentProps} from './component';
import type Component from './component';
import Component from './component';

// Create a property object
export function createProps<PropsT extends {}>(
Expand Down Expand Up @@ -66,6 +66,13 @@ const MergedDefaultPropsCacheKey = '_mergedDefaultProps';
// Return precalculated defaultProps and propType objects if available
// build them if needed
function getPropsPrototype(componentClass, extensions?: any[]) {
marsy-invests marked this conversation as resolved.
Show resolved Hide resolved
// Bail out if we're not looking at a component - for two reasons:
// 1. There's no reason for an ancestor of component to have props
// 2. If we don't bail out, we'll follow the prototype chain all the way back to the global
// function prototype and add _mergedDefaultProps to it, which may break other frameworks
// (e.g. the react-three-fiber reconciler)
if (!(componentClass instanceof Component.constructor)) return {};

// A string that uniquely identifies the extensions involved
let cacheKey = MergedDefaultPropsCacheKey;
if (extensions) {
Expand Down
Loading