React Using ReactJS with Typescript Stateless React Components in Typescript


Example

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.