Add note about refs on stateless components#7268
Add note about refs on stateless components#7268pke wants to merge 2 commits intofacebook:masterfrom pke:patch-1
Conversation
It was not mentioned that `ref` on stateless components does not work.
`<MyComp ref={element => this.listElement = element}/>`
If `MyComp` is a stateless/functional component then the `ref` method is always only ever called with `null`.
No warning is issued by react. See #7267
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
docs/docs/08.1-more-about-refs.md
Outdated
|
|
||
| > Important: | ||
| > | ||
| > `ref` attributes do **not work** on [stateless/functional components](/react/docs/reusable-components.html#stateless-functions) |
There was a problem hiding this comment.
Suggest changing this to "stateless functional components" since that is what seems to be used in other docs.
|
#7272 adds a warning for this |
|
Also duplicate #7267 |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
|
There is now a warning for this. New docs also mention this now. |
It was not mentioned that
refon stateless components does not work.<MyComp ref={element => this.listElement = element}/>If
MyCompis a stateless/functional component then therefmethod is always only ever called withnull.No warning is issued by react. See #7267