Skip to content

Commit d9a4644

Browse files
committed
Revert "fix(json-schema): schema 的 title 等属性在 react19 production 环境中无法传递组件 close #4307 (#4308)"
This reverts commit 2a474a6.
1 parent 2a474a6 commit d9a4644

File tree

3 files changed

+4
-26
lines changed

3 files changed

+4
-26
lines changed

packages/json-schema/src/__tests__/shared.spec.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import { isNoNeedCompileObject, createDataSource } from '../shared'
22
import { observable } from '@formily/reactive'
33
import { Schema } from '../schema'
4-
import React from 'react'
54

65
test('isNoNeedCompileObject', () => {
7-
function Test() {
8-
return null
9-
}
106
expect(isNoNeedCompileObject({})).toBeFalsy()
117
expect(isNoNeedCompileObject({ $$typeof: null, _owner: null })).toBeTruthy()
12-
expect(
13-
isNoNeedCompileObject(React.createElement(Test, {}, null))
14-
).toBeTruthy()
158
expect(isNoNeedCompileObject({ _isAMomentObject: true })).toBeTruthy()
169
expect(
1710
isNoNeedCompileObject({ [Symbol.for('__REVA_ACTIONS')]: true })

packages/json-schema/src/shared.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import {
2-
isFn,
3-
each,
4-
isPlainObj,
5-
isArr,
6-
toArr,
7-
FormPath,
8-
isReactElement,
9-
} from '@formily/shared'
1+
import { isFn, each, isPlainObj, isArr, toArr, FormPath } from '@formily/shared'
102
import { isObservable, untracked } from '@formily/reactive'
113
import { Schema } from './schema'
124
import { ISchema } from './types'
@@ -158,7 +150,7 @@ export const traverseSchema = (
158150
}
159151

160152
export const isNoNeedCompileObject = (source: any) => {
161-
if (isReactElement(source)) {
153+
if ('$$typeof' in source && '_owner' in source) {
162154
return true
163155
}
164156
if (source['_isAMomentObject']) {

packages/shared/src/checkers.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,8 @@ export const isNumberLike = (index: any): index is number =>
2121
isNum(index) || /^\d+$/.test(index)
2222
export const isObj = (val: unknown): val is object => typeof val === 'object'
2323
export const isRegExp = isType<RegExp>('RegExp')
24-
export const isReactElement = (obj: any): boolean => {
25-
// react19 production 环境中没有 _owner 属性
26-
return (
27-
isPlainObj(obj) &&
28-
'$$typeof' in obj &&
29-
('_owner' in obj || isFn(obj['type']))
30-
)
31-
}
32-
24+
export const isReactElement = (obj: any): boolean =>
25+
obj && obj['$$typeof'] && obj['_owner']
3326
export const isHTMLElement = (target: any): target is EventTarget => {
3427
return Object.prototype.toString.call(target).indexOf('HTML') > -1
3528
}

0 commit comments

Comments
 (0)