Skip to content

Commit

Permalink
fix(react): Import default for hoistNonReactStatics (#15238)
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome authored Jan 31, 2025
1 parent e3ee276 commit 25e7071
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
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

0 comments on commit 25e7071

Please sign in to comment.