MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / withProfiler

Function withProfiler

packages/react/src/profiler.tsx:154–174  ·  view source on GitHub ↗
(
  WrappedComponent: React.ComponentType<P>,
  // We do not want to have `updateProps` given in options, it is instead filled through the HOC.
  options?: Pick<Partial<ProfilerProps>, Exclude<keyof ProfilerProps, 'updateProps' | 'children'>>,
)

Source from the content-addressed store, hash-verified

152 */
153// eslint-disable-next-line @typescript-eslint/no-explicit-any
154function withProfiler<P extends Record<string, any>>(
155 WrappedComponent: React.ComponentType<P>,
156 // We do not want to have `updateProps` given in options, it is instead filled through the HOC.
157 options?: Pick<Partial<ProfilerProps>, Exclude<keyof ProfilerProps, 'updateProps' | 'children'>>,
158): React.FC<P> {
159 const componentDisplayName =
160 options?.name || WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
161
162 const Wrapped: React.FC<P> = (props: P) => (
163 <Profiler {...options} name={componentDisplayName} updateProps={props}>
164 <WrappedComponent {...props} />
165 </Profiler>
166 );
167
168 Wrapped.displayName = `profiler(${componentDisplayName})`;
169
170 // Copy over static methods from Wrapped component to Profiler HOC
171 // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
172 hoistNonReactStatics(Wrapped, WrappedComponent);
173 return Wrapped;
174}
175
176/**
177 *

Callers 3

profiler.test.tsxFile · 0.90
Index.jsxFile · 0.90

Calls 1

hoistNonReactStaticsFunction · 0.90

Tested by

no test coverage detected