Language:

Search

Stateless Functional Components in React

  • Share this:

A stateless component is just presentation of the state. It only can render props and it should only do that. A good example is a header component: let’s say we have a header which needs to be styled and displayed especially so we create a header stateless component which would look like this.

const Header = props => (
    <header className="header">
        <h1>TWT Header</h1>
        <h3 className="tagline">
            <span>{props.tagline}</span>
        </h3>
    </header>
);

 

 

Guest Contributor

Guest Contributor