mirror of
https://github.com/facebook/react.git
synced 2026-02-22 03:42:05 +00:00
Permit non-DEV Elements in React.Children w/ DEV (#32117)
This commit is contained in:
@@ -1039,6 +1039,31 @@ describe('ReactChildren', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('does not throw on children without `_store`', async () => {
|
||||
function ComponentRenderingFlattenedChildren({children}) {
|
||||
return <div>{React.Children.toArray(children)}</div>;
|
||||
}
|
||||
|
||||
const source = <div />;
|
||||
const productionElement = {};
|
||||
Object.entries(source).forEach(([key, value]) => {
|
||||
if (key !== '_owner' && key !== '_store') {
|
||||
productionElement[key] = value;
|
||||
}
|
||||
});
|
||||
Object.freeze(productionElement);
|
||||
|
||||
const container = document.createElement('div');
|
||||
const root = ReactDOMClient.createRoot(container);
|
||||
await act(() => {
|
||||
root.render(
|
||||
<ComponentRenderingFlattenedChildren>
|
||||
{productionElement}
|
||||
</ComponentRenderingFlattenedChildren>,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should escape keys', () => {
|
||||
const zero = <div key="1" />;
|
||||
const one = <div key="1=::=2" />;
|
||||
|
||||
@@ -813,7 +813,9 @@ export function cloneAndReplaceKey(oldElement, newKey) {
|
||||
);
|
||||
if (__DEV__) {
|
||||
// The cloned element should inherit the original element's key validation.
|
||||
clonedElement._store.validated = oldElement._store.validated;
|
||||
if (oldElement._store) {
|
||||
clonedElement._store.validated = oldElement._store.validated;
|
||||
}
|
||||
}
|
||||
return clonedElement;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user