react-solidlike 2.5.0 → 2.5.1

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.
Files changed (2) hide show
  1. package/dist/index.js +4 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -80,8 +80,10 @@ function For({ each, children, keyExtractor, fallback = null, wrapper, reverse }
80
80
  if (!each || each.length === 0) return fallback;
81
81
  const elements = (reverse ? [...each].reverse() : each).map((item, i) => {
82
82
  const originalIndex = reverse ? each.length - 1 - i : i;
83
- const key = keyExtractor ? keyExtractor(item, originalIndex) : originalIndex;
84
- return /* @__PURE__ */ jsx(Fragment, { children: children(item, originalIndex, each) }, key);
83
+ const child = children(item, originalIndex, each);
84
+ const childKey = isValidElement(child) ? child.key : null;
85
+ const key = keyExtractor ? keyExtractor(item, originalIndex) : childKey ?? originalIndex;
86
+ return /* @__PURE__ */ jsx(Fragment, { children: child }, key);
85
87
  });
86
88
  return wrapper && isValidElement(wrapper) ? cloneElement(wrapper, {}, elements) : elements;
87
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-solidlike",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "Declarative React control flow components inspired by Solid.js, replacing ternary expressions and array.map() in JSX",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",