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

Method componentWillUnmount

packages/react/src/profiler.tsx:105–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

103 // If a component is unmounted, we can say it is no longer on the screen.
104 // This means we can finish the span representing the component render.
105 public componentWillUnmount(): void {
106 const endTimestamp = timestampInSeconds();
107 const { name, includeRender = true } = this.props;
108
109 if (this._mountSpan && includeRender) {
110 const startTime = spanToJSON(this._mountSpan).timestamp;
111 withActiveSpan(this._mountSpan, () => {
112 const renderSpan = startInactiveSpan({
113 onlyIfParent: true,
114 name: `<${name}>`,
115 op: REACT_RENDER_OP,
116 startTime,
117 attributes: {
118 [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.react.profiler',
119 'ui.component_name': name,
120 },
121 });
122 if (renderSpan) {
123 // Have to cast to Span because the type of _mountSpan is Span | undefined
124 // and not getting narrowed properly
125 renderSpan.end(endTimestamp);
126 }
127 });
128 }
129 }
130
131 public render(): React.ReactNode {
132 return this.props.children;

Callers

nothing calls this directly

Calls 5

timestampInSecondsFunction · 0.90
spanToJSONFunction · 0.90
withActiveSpanFunction · 0.90
endMethod · 0.65
startInactiveSpanFunction · 0.50

Tested by

no test coverage detected