Skip to content

Commit

Permalink
Merge pull request #6419 from IvanVergiliev/master
Browse files Browse the repository at this point in the history
Add documentation about empty functional components
(cherry picked from commit 62f64a8)
  • Loading branch information
jimfb authored and zpao committed Apr 7, 2016
1 parent c491664 commit 1942c6a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/docs/05-reusable-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,8 @@ 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.
> NOTE:
>
> In React v0.14, stateless functional components were not permitted to return `null` or `false` (a workaround is to return a `<noscript />` instead). This was fixed in React v15, and stateless functional components are now permitted to return `null`.
In an ideal world, most of your components would be stateless functions because in the future we’ll 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.

0 comments on commit 1942c6a

Please sign in to comment.