Hacker News new | past | comments | ask | show | jobs | submit login

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:

    function renderFoo(props) {
        return <span>{props.foo}</span>;
    }
Then use it elsewhere in your code like a normal function:

    function bar(props) {
        return <div>{props.foos.map(renderFoo)}</div>;
    }



Looks like they've just added first-class support for that pattern, so you get propTypes, defaultProps, etc.


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)




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: