Skip to content

Iterators are not supported inside Component.render #11502

Description

@askoretskiy

What is the current behavior?

When you provide a list of React components -- its works. When you provide an iterator of React components -- it does not work.

This works:

const App = props => (
    <ul>
        {[...elements()]}
    </ul>
);

const elements = function* () {
    yield (<li>1</li>);
    yield (<li>2</li>);
    yield (<li>3</li>);
};

Doesn't work:

const App = props => (
    <ul>
        {elements()}
    </ul>
);

const elements = function* () {
    yield (<li>1</li>);
    yield (<li>2</li>);
    yield (<li>3</li>);
};

Unfortunately, I couldn't make it run on JSFiddle, maybe it has no support of iterators.

What is the expected behavior?

It should render exactly the same version as list-based one:

  • 1
  • 2
  • 3

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

react-dom 16.0.0 and 15.x, browser-independent (I tried in Firefox 56).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions