Skip to content

Commit

Permalink
fix: fix signals are not reactive on lazy imported components.(preact…
Browse files Browse the repository at this point in the history
  • Loading branch information
yi.wang.sh committed Apr 10, 2023
1 parent 9a5cbbd commit fae70c9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>,
FunctionComponent<any>
Expand Down Expand Up @@ -166,6 +167,10 @@ function WrapJsx<T>(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];
Expand Down

0 comments on commit fae70c9

Please sign in to comment.