Skip to content
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

Warn when using one-shot iterators as children #24470

Closed
wants to merge 3 commits into from

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Apr 29, 2022

Summary

Closes #20707 by adding a warning when using one-shot iterators.

How did you test this change?

expect(() => {
ReactDOM.render(<Foo />, div);
}).toErrorDev(
'Using a TOOD-understandable-term as children is unsupported and will likely yield ' +
Copy link
Collaborator Author

@eps1lon eps1lon Apr 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried googling "one-shot iterator" and could only find mention of it related to tensorflow. Is this really a proper term in JS-land? Even if, we probably want to add an example "Using a one-shot iterator (e.g. Array.prototype.values()) as children [...]". What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just iterator?

Using an iterator such as [].values() as children is unsupported and will likely yield unexpected results because it can only be iterated once. You may convert it [...]

@sizebot
Copy link

sizebot commented Apr 29, 2022

Comparing: 8ee4f52...1610922

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 135.28 kB 135.28 kB = 43.39 kB 43.39 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 142.74 kB 142.74 kB = 45.58 kB 45.58 kB
facebook-www/ReactDOM-prod.classic.js = 490.70 kB 490.70 kB = 87.32 kB 87.32 kB
facebook-www/ReactDOM-prod.modern.js = 475.99 kB 475.99 kB = 85.13 kB 85.13 kB
facebook-www/ReactDOMForked-prod.classic.js = 490.70 kB 490.70 kB = 87.32 kB 87.32 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 1610922

@eps1lon eps1lon changed the title Add missing item to the changelog Warn when using one-shot iterators as children Apr 29, 2022
@eps1lon eps1lon marked this pull request as ready for review April 29, 2022 17:08
@eps1lon eps1lon force-pushed the feat/warn-one-shot-iterators branch from da5beb1 to ec0709a Compare May 12, 2022 06:25
@eps1lon eps1lon force-pushed the feat/warn-one-shot-iterators branch from ec0709a to c74ca65 Compare July 2, 2022 07:20
Copy link

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Apr 10, 2024
Copy link

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

@github-actions github-actions bot closed this Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Resolution: Stale Automatically closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Iterator as JSX children doesn't work right
4 participants