Comment

Comment by dustingetz

Functions are components! Yay! Here's the quote:

In idiomatic React code, most of the components you write will be stateless, simply composing other components. We’re introducing a new, simpler syntax for these components where you can take props as an argument and return the element you want to render:

    // Using an ES2015 (ES6) arrow function:
    var Aquarium = (props) => {
      return <Tank>{getFish(props.species)}</Tank>;
    };
    
    // Or with destructuring and an implicit return, simply:
    var Aquarium = ({species}) => (
      <Tank>{getFish(species)}</Tank>
    );
    
    // Then use: <Aquarium species="rainbowfish" />
parent dustingetz 11 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton