Saying inline functions in render is bad is like correcting somebody who said "who" to say "whom" when "who" was actually correct.
-
-
-
And if there's only one child this.props.children is the child? Or this.props.children[0]?
-
Right, a single child would be available as this.props.children. You can use React.Children.only to ensure you only have a single child too
-
Wouldn't it be more convenient to have direct syntax for this in JSX?
-
I believe that is some people’s objection. Children as a function is not a valid type for children according to docs.
-
It's fine. People are just prematurely optimizing and its starting to spread. That's all.
-
Also, the docs explicitly state functions as children is a valid, seehttps://facebook.github.io/react/docs/jsx-in-depth.html#functions-as-children …
-
Glad to see it officially supported. My only objection was what if it disappeared. Didn’t want to rely on an unsupported API/feature
- 6 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.