diff --git a/src/frontends/react/HelloWorld.tsx b/src/frontends/react/HelloWorld.tsx index 9d3fc96..611037d 100644 --- a/src/frontends/react/HelloWorld.tsx +++ b/src/frontends/react/HelloWorld.tsx @@ -2,7 +2,7 @@ import React from "react"; import useShape from "../../ng-mock/js-land/frontendAdapters/react/useShape"; export function HelloWorldReact() { - const state = useShape("Shape2", ""); + const state = useShape("Shape1", ""); window.reactState = state; console.log("react render", state); diff --git a/src/ng-mock/js-land/connector/ngSignals.ts b/src/ng-mock/js-land/connector/ngSignals.ts index 5a8aa8a..2813423 100644 --- a/src/ng-mock/js-land/connector/ngSignals.ts +++ b/src/ng-mock/js-land/connector/ngSignals.ts @@ -5,8 +5,12 @@ import { applyDiff } from "./applyDiff"; import { batch, deepSignal, watch } from "alien-deepsignals"; import { signal } from "alien-signals"; +const openConnections: Record> = {}; + // TODO: The code is horrible. export function createSignalObjectForShape(shape: Shape, scope?: Scope) { + if (openConnections[shape]) return openConnections[shape]; + // TODO: // DeepSignal has a different API to alien-signals. // Therefore, we need to create a "root signal" wrapper that is @@ -66,5 +70,6 @@ export function createSignalObjectForShape(shape: Shape, scope?: Scope) { } ); + openConnections[shape] = rootSignal; return rootSignal; }