-
Notifications
You must be signed in to change notification settings - Fork 49.8k
Permit non-DEV Elements in React.Children w/ DEV
#32117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1039,6 +1039,32 @@ describe('ReactChildren', () => { | |
| }); | ||
| }); | ||
|
|
||
| // @gate __DEV__ | ||
| 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; | ||
| } | ||
| }); | ||
|
Comment on lines
+1049
to
+1053
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way this test case needs to be contrived signals that this mix of environments should really not be supported. We could consider adding build types to the version checks to prevent apps from relying on these setups in the future.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect you encounter this in development when you use 3rd party libraries that only have a single entrypoint with JSX compiled for production. Would require a lot of heavy lifting if we require libraries to ship both dev and prod entrypoints. |
||
| 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" />; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this line in my latest commit a7b0192 as it should work for both dev and prod