Questions And Answers

More Tutorials

React Stateless and property-less Components

The simplest react component without a state and no properties can be written as:

import * as React from 'react';
const Greeter = () => <span>Hello, World!</span>

That component, however, can't access this.props since typescript can't tell if it is a react component. To access its props, use:

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 similar good use of stateless and property-less components is in simple page templating. The following is an examplinary simple Page component, assuming there are hypothetical Container, NavTop and NavBottom components already in the project:

import * as React from 'react';
const Page: React.SFC<{}> = props => () =>
 <NavTop />
 <NavBottom />
const LoginPage: React.SFC<{}> = props => () =>
 Login Pass: <input type="password" />

In this example, the Page component can later be used by any other actual page as a base template.


In this page (written and validated by ) you learned about React Stateless and property-less Components . What's Next? If you are interested in completing React tutorial, your next topic will be learning about: React State.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.