Merge pull request #5885 from knpwrs/patch-1

Clarify stateless function component optimizations.
(cherry picked from commit 7cee5022f8)
This commit is contained in:
Jim
2016-01-28 09:53:58 -08:00
committed by Paul O’Shannessy
parent da3c9527c5
commit f5dd3e7cf6
+1 -1
View File
@@ -254,4 +254,4 @@ However, you may still specify `.propTypes` and `.defaultProps` by setting them
>
> Because stateless functions don't have a backing instance, you can't attach a ref to a stateless function component. Normally this isn't an issue, since stateless functions do not provide an imperative API. Without an imperative API, there isn't much you could do with an instance anyway. However, if a user wants to find the DOM node of a stateless function component, they must wrap the component in a stateful component (eg. ES6 class component) and attach the ref to the stateful wrapper component.
In an ideal world, most of your components would be stateless functions because these stateless components can follow a faster code path within the React core. This is the recommended pattern, when possible.
In an ideal world, most of your components would be stateless functions because in the future well also be able to make performance optimizations specific to these components by avoiding unnecessary checks and memory allocations. This is the recommended pattern, when possible.