@samitouri / QOS-React / commits / 16f64c4499

Document stateless components in formal types

Adam Stankiewicz committed Apr 27, 2016 at 09:11 UTC 16f64c4499eac272b0fb8b11162e225cdf26d814
1 file changed +4 -1
docs/docs/ref-10-glossary.md
+4 -1
@@ -137,6 +137,7 @@ This is why you shouldn't construct your own instance. Instead, `ReactElement` i
137
138 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.
139
140 +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`.
141
142 ## Formal Type Definitions
143
@@ -165,7 +166,7 @@ type ReactDOMElement = {
166 };
167
168 type ReactComponentElement<TProps> = {
168 - type : ReactClass<TProps>,
169 + type : ReactClass<TProps> | ReactFunctionalComponent<TProps>,
170 props : TProps,
171 key : string | boolean | number | null,
172 ref : string | null
@@ -189,5 +190,7 @@ type ReactComponent<TProps> = {
190 props : TProps,
191 render : () => ReactElement
192 };
193 +
194 +type ReactFunctionalComponent<TProps> = (TProps) => ReactElement;
195 ```
196