Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 2fa0322

Browse files
authored
Merge pull request #322 from noverby/fix-react-component-detection
react: fix detection of react components
2 parents b17d1ee + e3f7119 commit 2fa0322

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

framework/react/helper.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,7 @@ export const inDeno = typeof Deno !== 'undefined' && typeof Deno.version?.deno =
99
export function isLikelyReactComponent(type: any, strict = true): Boolean {
1010
switch (typeof type) {
1111
case 'function':
12-
if (type.prototype != null) {
13-
if (type.prototype.isReactComponent) {
14-
return true
15-
}
16-
const ownNames = Object.getOwnPropertyNames(type.prototype)
17-
if (ownNames.length > 1 || ownNames[0] !== 'constructor') {
18-
return false
19-
}
20-
}
21-
if (!strict) {
22-
// don't check component name
23-
return true
24-
}
25-
const { __ALEPH: ALEPH } = window as any
26-
if (ALEPH) {
27-
// in bundle mode, the component names have been compressed.
28-
return true
29-
}
30-
const name = type.displayName || type.name
31-
return typeof name === 'string' && /^[A-Z]/.test(name)
12+
return true
3213
case 'object':
3314
if (type != null) {
3415
switch (type.$$typeof) {

0 commit comments

Comments
 (0)