Match-id-3314488ef0f0a3913b65712abcdb657534438dc2
This commit is contained in:
parent
824b243b9e
commit
43602a11f2
|
@ -13,12 +13,20 @@
|
|||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
import { TYPE_FORWARD_REF } from '../../external/JSXElementType';
|
||||
import {TYPE_FORWARD_REF, TYPE_MEMO} from '../../external/JSXElementType';
|
||||
|
||||
export function forwardRef(render: Function) {
|
||||
return {
|
||||
vtype: TYPE_FORWARD_REF,
|
||||
$$typeof: TYPE_FORWARD_REF, // 规避三方件hoist-non-react-statics中,通过$$typeof获取类型,但获取不到导致的错误
|
||||
const forwardRefJSXElement = {
|
||||
$$typeof: TYPE_FORWARD_REF, // 规避三方件hoist-non-react-statics中,通过$$typeof获取类型,但获取不到,导致render被覆盖
|
||||
render,
|
||||
};
|
||||
|
||||
// 控制vtype不能修改,规避三方件hoist-non-react-statics修改vtype导致问题
|
||||
Object.defineProperty(forwardRefJSXElement, 'vtype', {
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: TYPE_FORWARD_REF,
|
||||
});
|
||||
|
||||
return forwardRefJSXElement;
|
||||
}
|
||||
|
|
|
@ -16,9 +16,18 @@
|
|||
import { TYPE_MEMO } from '../../external/JSXElementType';
|
||||
|
||||
export function memo<Props>(type, compare?: (oldProps: Props, newProps: Props) => boolean) {
|
||||
return {
|
||||
vtype: TYPE_MEMO,
|
||||
const memoJSXElement = {
|
||||
$$typeof: TYPE_MEMO, // 规避三方件hoist-non-react-statics中,通过$$typeof获取类型,但获取不到,导致type被覆盖
|
||||
type: type,
|
||||
compare: compare === undefined ? null : compare,
|
||||
};
|
||||
|
||||
// 控制vtype不能修改,规避三方件hoist-non-react-statics修改vtype导致问题
|
||||
Object.defineProperty(memoJSXElement, 'vtype', {
|
||||
configurable: false,
|
||||
writable: false,
|
||||
value: TYPE_MEMO,
|
||||
});
|
||||
|
||||
return memoJSXElement;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue