react-spot 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/fiber-utils.ts +11 -7
package/package.json
CHANGED
package/src/core/fiber-utils.ts
CHANGED
|
@@ -252,13 +252,17 @@ export function getStackFrame(fiber: Fiber): string | undefined {
|
|
|
252
252
|
function isSelfFrame(frameLine: string, componentName: string): boolean {
|
|
253
253
|
// 提取帧中的函数名:匹配 "at FuncName (" 或 "FuncName@" 格式
|
|
254
254
|
const atMatch = frameLine.match(/^at\s+([^\s(]+)/);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
|
|
255
|
+
const frameName = atMatch?.[1] ?? frameLine.match(/^([^@]+)@/)?.[1];
|
|
256
|
+
if (!frameName) return false;
|
|
257
|
+
|
|
258
|
+
// 直接匹配
|
|
259
|
+
if (frameName === componentName) return true;
|
|
260
|
+
|
|
261
|
+
// Memo(InnerName) / ForwardRef(InnerName) 包装:
|
|
262
|
+
// getComponentName 返回 "Memo(Foo)" 但 React 19 自身帧用的是内部函数名 "Foo"
|
|
263
|
+
const innerMatch = componentName.match(/^(?:Memo|ForwardRef)\((.+)\)$/);
|
|
264
|
+
if (innerMatch && frameName === innerMatch[1]) return true;
|
|
265
|
+
|
|
262
266
|
return false;
|
|
263
267
|
}
|
|
264
268
|
|