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

fix(react): Import default for hoistNonReactStatics #15238

Merged
merged 5 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/react/src/errorboundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { ReportDialogOptions } from '@sentry/browser';
import { getClient, showReportDialog, withScope } from '@sentry/browser';
import { logger } from '@sentry/core';
import type { Scope } from '@sentry/core';
import hoistNonReactStatics from 'hoist-non-react-statics';
import * as React from 'react';
import { hoistNonReactStatics } from './hoist-non-react-statics';

import { DEBUG_BUILD } from './debug-build';
import { captureReactException } from './error';
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/hoist-non-react-statics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as hoistNonReactStaticsImport from 'hoist-non-react-statics';

// Ensure we use the default export from hoist-non-react-statics if available,
// falling back to the module itself. This handles both ESM and CJS usage.
export const hoistNonReactStatics = hoistNonReactStaticsImport.default || hoistNonReactStaticsImport;
4 changes: 2 additions & 2 deletions packages/react/src/profiler.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { startInactiveSpan } from '@sentry/browser';
import type { Span } from '@sentry/core';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON, timestampInSeconds, withActiveSpan } from '@sentry/core';
import hoistNonReactStatics from 'hoist-non-react-statics';
import * as React from 'react';

import { REACT_MOUNT_OP, REACT_RENDER_OP, REACT_UPDATE_OP } from './constants';
import { hoistNonReactStatics } from './hoist-non-react-statics';

export const UNKNOWN_COMPONENT = 'unknown';

Expand Down Expand Up @@ -236,4 +236,4 @@ function useProfiler(
}, []);
}

export { withProfiler, Profiler, useProfiler };
export { Profiler, useProfiler, withProfiler };
2 changes: 1 addition & 1 deletion packages/react/src/reactrouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
spanToJSON,
} from '@sentry/core';
import type { Client, Integration, Span, TransactionSource } from '@sentry/core';
import hoistNonReactStatics from 'hoist-non-react-statics';
import * as React from 'react';
import type { ReactElement } from 'react';
import { hoistNonReactStatics } from './hoist-non-react-statics';

import type { Action, Location } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/reactrouterv6-compat-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
} from '@sentry/core';
import * as React from 'react';

import hoistNonReactStatics from 'hoist-non-react-statics';
import { DEBUG_BUILD } from './debug-build';
import { hoistNonReactStatics } from './hoist-non-react-statics';
import type {
Action,
AgnosticDataRouteMatch,
Expand Down
Loading