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. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,7 @@ function linkifyChildren(children: ReactNode, keyPrefix = 'l'): ReactNode {
|
|||||||
const grandchildren = el.props.children;
|
const grandchildren = el.props.children;
|
||||||
if (grandchildren === undefined) return child;
|
if (grandchildren === undefined) return child;
|
||||||
return cloneElement(el, {
|
return cloneElement(el, {
|
||||||
|
key: el.key ?? `linkified-${i}`,
|
||||||
children: linkifyChildren(grandchildren, `${keyPrefix}-${i}`),
|
children: linkifyChildren(grandchildren, `${keyPrefix}-${i}`),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user