From 16f64c4499eac272b0fb8b11162e225cdf26d814 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 27 Apr 2016 09:11:13 +0200 Subject: [PATCH] Document stateless components in formal types --- docs/docs/ref-10-glossary.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/docs/ref-10-glossary.md b/docs/docs/ref-10-glossary.md index f5e5533053..ab553e07d0 100644 --- a/docs/docs/ref-10-glossary.md +++ b/docs/docs/ref-10-glossary.md @@ -137,6 +137,7 @@ This is why you shouldn't construct your own instance. Instead, `ReactElement` i The `render` method of a `ReactComponent` is expected to return another `ReactElement`. This allows these components to be composed. Ultimately the render resolves into `ReactElement` with a `string` tag which instantiates a DOM `Element` instance and inserts it into the document. +React 0.14 introduced [stateless functional components](/react/blog/2015/10/07/react-v0.14.html#stateless-functional-components) as an alternative way of defining components. Instead of being a class, it is a simple function that accepts props and is expected to return a `ReactElement`. ## Formal Type Definitions @@ -165,7 +166,7 @@ type ReactDOMElement = { }; type ReactComponentElement = { - type : ReactClass, + type : ReactClass | ReactFunctionalComponent, props : TProps, key : string | boolean | number | null, ref : string | null @@ -189,5 +190,7 @@ type ReactComponent = { props : TProps, render : () => ReactElement }; + +type ReactFunctionalComponent = (TProps) => ReactElement; ```