Skip to content

docs: document that Component.render can return iterables#8473

Open
sawirricardo wants to merge 1 commit into
reactjs:mainfrom
sawirricardo:docs/render-iterator-note
Open

docs: document that Component.render can return iterables#8473
sawirricardo wants to merge 1 commit into
reactjs:mainfrom
sawirricardo:docs/render-iterator-note

Conversation

@sawirricardo

Copy link
Copy Markdown

Summary

Documents that Component.render() can return iterables, addressing issue #286.

Changes

Added documentation to the render() returns section in the Component reference docs noting that:

  1. render() can return iterables (e.g., from generators), not just arrays and JSX elements.
  2. Includes a Pitfall warning that single-use iterators only work in production builds — in development, React calls render twice (Strict Mode), which exhausts the iterator on the second call.
  3. Recommends using proper iterable objects or Fragment instead.

Related issues

Closes #286

Closes reactjs#286

Add a note in the Component.render reference docs that render() can
return iterables (e.g. from generators). Include a Pitfall warning
that iterators (single-use) only work in production builds since
React calls render twice in development, and recommend using iterables
or Fragment instead.
@github-actions

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mention that Component.render could return iterator

1 participant