batch3 T8 review fix: preserve cloneElement key in linkifyChildren

cloneElement does not carry el.key through unless explicitly passed.
Without it, react-markdown's inline-element siblings (strong/em/text)
lose their reconciler keys on every render, causing potential diffing
churn. Pass el.key (with fallback) explicitly.
This commit is contained in:
2026-05-15 15:58:45 +00:00
parent f12b93366d
commit b41c69d3ad

View File

@@ -74,6 +74,7 @@ function linkifyChildren(children: ReactNode, keyPrefix = 'l'): ReactNode {
const grandchildren = el.props.children;
if (grandchildren === undefined) return child;
return cloneElement(el, {
key: el.key ?? `linkified-${i}`,
children: linkifyChildren(grandchildren, `${keyPrefix}-${i}`),
});
}