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

Method shouldComponentUpdate

packages/react/src/profiler.tsx:67–94  ·  view source on GitHub ↗
({ updateProps, includeUpdates = true }: ProfilerProps)

Source from the content-addressed store, hash-verified

65 }
66
67 public shouldComponentUpdate({ updateProps, includeUpdates = true }: ProfilerProps): boolean {
68 // Only generate an update span if includeUpdates is true, if there is a valid mountSpan,
69 // and if the updateProps have changed. It is ok to not do a deep equality check here as it is expensive.
70 // We are just trying to give baseline clues for further investigation.
71 if (includeUpdates && this._mountSpan && updateProps !== this.props.updateProps) {
72 // See what props have changed between the previous props, and the current props. This is
73 // set as data on the span. We just store the prop keys as the values could be potentially very large.
74 const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);
75 if (changedProps.length > 0) {
76 const now = timestampInSeconds();
77 this._updateSpan = withActiveSpan(this._mountSpan, () => {
78 return startInactiveSpan({
79 name: `<${this.props.name}>`,
80 onlyIfParent: true,
81 op: REACT_UPDATE_OP,
82 startTime: now,
83 attributes: {
84 [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.react.profiler',
85 'ui.component_name': this.props.name,
86 'ui.react.changed_props': changedProps,
87 },
88 });
89 });
90 }
91 }
92
93 return true;
94 }
95
96 public componentDidUpdate(): void {
97 if (this._updateSpan) {

Callers

nothing calls this directly

Calls 4

timestampInSecondsFunction · 0.90
withActiveSpanFunction · 0.90
keysMethod · 0.65
startInactiveSpanFunction · 0.50

Tested by

no test coverage detected