GeezerVison is showing github.com — fix: 修复React17选中组件bug · yourkeychen/lowcode-engine@750d282
File tree
Expand file treeCollapse file tree
Open diff view settings
rax-simulator-renderer/src react-simulator-renderer/src
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/rax-simulator-renderer/src/renderer.ts +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -73,7 +73,10 @@ function cacheReactKey(el: Element): Element { |
73 | 73 | if (REACT_KEY !== '') { |
74 | 74 | return el; |
75 | 75 | } |
76 | | - REACT_KEY = Object.keys(el).find((key) => key.startsWith('__reactInternalInstance$')) || ''; |
| 76 | + // react17 采用 __reactFiber 开头 |
| 77 | + REACT_KEY = Object.keys(el).find( |
| 78 | + (key) => key.startsWith('__reactInternalInstance$') || key.startsWith('__reactFiber$'), |
| 79 | + ) || ''; |
77 | 80 | if (!REACT_KEY && (el as HTMLElement).parentElement) { |
78 | 81 | return cacheReactKey((el as HTMLElement).parentElement!); |
79 | 82 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-simulator-renderer/src/renderer.ts +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -530,7 +530,10 @@ function cacheReactKey(el: Element): Element { |
530 | 530 | if (REACT_KEY !== '') { |
531 | 531 | return el; |
532 | 532 | } |
533 | | - REACT_KEY = Object.keys(el).find((key) => key.startsWith('__reactInternalInstance$')) || ''; |
| 533 | + // react17 采用 __reactFiber 开头 |
| 534 | + REACT_KEY = Object.keys(el).find( |
| 535 | + (key) => key.startsWith('__reactInternalInstance$') || key.startsWith('__reactFiber$'), |
| 536 | + ) || ''; |
534 | 537 | if (!REACT_KEY && (el as HTMLElement).parentElement) { |
535 | 538 | return cacheReactKey((el as HTMLElement).parentElement!); |
536 | 539 | } |
|