Stateless React Components in Typescript

suggest change

React components that are pure functions of their props and do not require any internal state can be written as JavaScript functions instead of using the standard class syntax, as:

import React from 'react'const HelloWorld = (props) => (<h1>Hello, {props.name}!</h1>);

The same can be achieved in Typescript using the React.SFC class:

import * as React from 'react';

class GreeterProps {
   name: string
}

const Greeter : React.SFC<GreeterProps> = props =>
    <h1>Hello, {props.name}!</h1>;

Note that, the name React.SFC is an alias for React.StatelessComponent So, either can be used.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


React with TypeScript:
*Stateless React Components in Typescript

Table Of Contents