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

Add documentation about empty functional components #6419

Merged
merged 2 commits into from
Apr 7, 2016

Conversation

IvanVergiliev
Copy link
Contributor

@IvanVergiliev IvanVergiliev commented Apr 5, 2016

The dev build has a warning about this, but there's no obvious course of action to actually make it work. Also, I think adding this to the docs makes migrating existing components easier.

@jimfb
Copy link
Contributor

jimfb commented Apr 5, 2016

This is fixed in v15 (stateless function components can now return null). I'm going to close this out because we are in the process of shipping v15 and by the time this got merged and cherry-picked over, we'd already be on v15 and would have to do another PR to remove this note.

If you're interested, this was fixed in: #5884

The note is great. Just the timing is wrong. A month or two ago, we would gladly have accepted this PR!

@jimfb jimfb closed this Apr 5, 2016
@zpao
Copy link
Member

zpao commented Apr 5, 2016

Do you think it might make sense to have some docs about this and just call out that it only applies in v0.14 but 15 does work? I think we're somewhat likely to see reports from people still using 14 but reading the 14 docs and getting the wrong idea.

@jimfb
Copy link
Contributor

jimfb commented Apr 5, 2016

Yeah, alright, I could get behind that.

@jimfb jimfb reopened this Apr 5, 2016
@jimfb
Copy link
Contributor

jimfb commented Apr 5, 2016

@IvanVergiliev Can you update the note to indicate that this applies to v0.14, and that this was fixed in v15 such that stateless functions can now return null.

Perhaps:

In React v0.14, stateless functional components were not permitted to return null or false (a workaround is to return a <noscript /> instead). This was fixed in React v15, and stateless functional components are now permitted to return null.

@IvanVergiliev
Copy link
Contributor Author

Thanks for the quick response!

Happy to hear this is possible now. I also think it's a good idea to include it in the docs as I was in the process of updating 2048-react but decided to do it version by version so I can better see what changed. Without such a note (or this discussion) it would've been a while before I understood I can actually return null in v15.

@jimfb jimfb self-assigned this Apr 6, 2016
@jimfb jimfb merged commit 62f64a8 into facebook:master Apr 7, 2016
zpao pushed a commit that referenced this pull request Apr 7, 2016
Add documentation about empty functional components
(cherry picked from commit 62f64a8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants