Stateless and property-less Components
suggest changeThe simplest React component, with no state and no properties, can be written as:
import * as React from 'react';
const Greeter = () => <span>Hello, World!</span>
A plain function has no this.props. To type it as a React function component and read props (including props.children), annotate it. Do not return another function; the component itself must return an element. React.SFC was later renamed React.FC.
import * as React from 'react';
const Greeter: React.SFC<{}> = props => <span>Hello, World!</span>
Even if the component doesn’t have explicitly defined properties, it can now access props.children since all components inherently have children.
Another good use of stateless, property-less components is simple page templating. The following is a simple Page component, assuming Container, NavTop, and NavBottom already exist in the project:
import * as React from 'react';
const Page: React.SFC<{}> = props =>
<Container>
<NavTop />
{props.children}
<NavBottom />
</Container>
const LoginPage: React.SFC<{}> = props =>
<Page>
Login Pass: <input type="password" />
</Page>
In this example, the Page component can later be used by any other actual page as a base template.