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

Possibility to return multiple elements from render() #7354

Closed
xkr47 opened this issue Jul 26, 2016 · 1 comment
Closed

Possibility to return multiple elements from render() #7354

xkr47 opened this issue Jul 26, 2016 · 1 comment

Comments

@xkr47
Copy link

xkr47 commented Jul 26, 2016

This can be seen as an extension of #7353

I'm asking if, in the light of #5753, it would be possible to return an array with multiple elements (and maybe strings too) from render(). Currently it is already possible to return an array with a mix of elements & strings from a {} block in JSX. Could the same comment-wrapping method from 5573 allow for this also for render methods?

// Before
<h1>Hello</h1>
{elements.map((elem) => <div>{elem}</div>)}
// After
<h1>Hello</h1>
<ComponentProducingMultipleDivs elements={elements} />

Motivation is that it is sometimes hard to get layout to work as expected if one has to wrap the list of elements in some other element, and the alternative is to write plain functions instead of react components to produce the expected result. It would be syntactically nice to be able to componentize multiple-output components.

@gaearon
Copy link
Collaborator

gaearon commented Jul 26, 2016

This is planned to be implemented eventually.
Please see #2127.

This issue was closed.
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

No branches or pull requests

2 participants