From fae70c94ae44ed9e2fc7999af7dbc3df083ec2bb Mon Sep 17 00:00:00 2001 From: "yi.wang.sh" Date: Mon, 10 Apr 2023 19:26:06 +0800 Subject: [PATCH] fix: fix signals are not reactive on lazy imported components.(#301) --- packages/react/src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index 570656d71..a0f8ff227 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -24,6 +24,7 @@ export { signal, computed, batch, effect, Signal, type ReadonlySignal }; const Empty = [] as const; const ReactElemType = Symbol.for("react.element"); // https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15 const ReactMemoType = Symbol.for("react.memo"); // https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L30 +const ReactLazyType = Symbol.for("react.lazy"); // https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L31 const ProxyInstance = new WeakMap< FunctionComponent, FunctionComponent @@ -166,6 +167,10 @@ function WrapJsx(jsx: T): T { return jsx.call(jsx, type, props, ...rest); } + if (type && typeof type === "object" && type.$$typeof === ReactLazyType) { + return jsx.call(jsx, ProxyFunctionalComponent(type._init(type._payload)), props, ...rest); + } + if (typeof type === "string" && props) { for (let i in props) { let v = props[i];