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 pure text from render() without wrapping it in an element #7353

Closed
xkr47 opened this issue Jul 26, 2016 · 5 comments
Closed

Comments

@xkr47
Copy link

xkr47 commented Jul 26, 2016

I'm asking if, in the light of #5753, it would be possible to also return plain text from render() as an alternative to the current ReactElement return type such that one would not have to wrap it in an element. Could the same comment-wrapping method allow for this also for render methods?

// Before
return <span>{this.props.text}</span>;
// After
return this.props.text;

Motivation is that it is sometimes hard to get layout to work as expected if one has to introduce span elements, 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 text-only components the same way as "html-enabled" components.

@stephenkingsley
Copy link

I think this is convenient. and the code look like simplify.

@syranide
Copy link
Contributor

@xkr47 Not disagreeing. But be mindful of overusing text-only components, components have non-trivial overhead and could have significant performance impact if overused.

@xkr47
Copy link
Author

xkr47 commented Jul 27, 2016

@syranide true.. are there any benchmark results on these kinds of things? inline vs function call vs stateless component vs stateful component..?

@gaearon
Copy link
Collaborator

gaearon commented Oct 27, 2016

FWIW this is already implemented in Fiber (#6170).
We won't be bringing this to the old reconciler.

@aweary
Copy link
Contributor

aweary commented Apr 21, 2017

Closing this since it's already implemented in the next major and it won't be added to any 15.5 release

@aweary aweary closed this as completed Apr 21, 2017
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

5 participants