@creact-labs/creact 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -26,7 +26,7 @@ function shallowEqual(a, b) {
|
|
|
26
26
|
}
|
|
27
27
|
// Registry of all instance nodes by ID
|
|
28
28
|
const nodeRegistry = new Map();
|
|
29
|
-
// Track which fiber owns each nodeId (to detect duplicate siblings)
|
|
29
|
+
// Track which fiber path owns each nodeId (to detect duplicate siblings)
|
|
30
30
|
const nodeOwnership = new Map();
|
|
31
31
|
// Output hydration map - populated before render to restore outputs from previous run
|
|
32
32
|
const outputHydrationMap = new Map();
|
|
@@ -99,16 +99,17 @@ export function useInstance(construct, props) {
|
|
|
99
99
|
}
|
|
100
100
|
const constructType = construct.name || 'Unknown';
|
|
101
101
|
// Check for duplicate siblings (requires keys)
|
|
102
|
-
// Allow same fiber to re-register (reactive re-render), but not different
|
|
103
|
-
const
|
|
104
|
-
|
|
102
|
+
// Allow same fiber path to re-register (reactive re-render), but not different paths
|
|
103
|
+
const existingOwnerPath = nodeOwnership.get(nodeId);
|
|
104
|
+
const currentFiberPath = fiber.path.join('.');
|
|
105
|
+
if (existingOwnerPath && existingOwnerPath !== currentFiberPath) {
|
|
105
106
|
throw new Error(`Multiple instances of ${constructType} at the same level require unique keys.\n` +
|
|
106
107
|
`Add a key prop to differentiate them:\n\n` +
|
|
107
108
|
` {items.map((item) => (\n` +
|
|
108
109
|
` <MyResource key={item.id} ... />\n` +
|
|
109
110
|
` ))}`);
|
|
110
111
|
}
|
|
111
|
-
nodeOwnership.set(nodeId,
|
|
112
|
+
nodeOwnership.set(nodeId, currentFiberPath);
|
|
112
113
|
// Create or get existing node
|
|
113
114
|
let node = nodeRegistry.get(nodeId);
|
|
114
115
|
if (!node) {
|