Re:React v0.14
by smadge on Wednesday October 07, 2015 @03:26PM
(#10348391)
What exactly is different? I've been using "stateless function components" with react 0.12 and 0.13. Just write a function that returns a ReactElement, eg:
Then use it elsewhere in your code like a normal function:
[ Parent
| on HN ]
Looks like they've just added first-class support for that pattern, so you get propTypes, defaultProps, etc.
Re:React v0.14
by danabramov on Wednesday October 07, 2015 @04:59PM
(#10349055)
Also in the future this pattern will be faster thanks to React not having to maintain an internal instance for such components.
(How's that different from just a function? It shows up as separate thing in React DevTools, it can have default props or, in the future, shouldComponentUpdate (or built-in memoization strategy?), you can potentially later change it to be stateful without rewriting consuming code, etc)