Skip to content

Conversation

@pke
Copy link

@pke pke commented Jul 13, 2016

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

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
@ghost
Copy link

ghost commented Jul 13, 2016

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!


> Important:
>
> `ref` attributes do **not work** on [stateless/functional components](/react/docs/reusable-components.html#stateless-functions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest changing this to "stateless functional components" since that is what seems to be used in other docs.

@ghost ghost added the CLA Signed label Jul 13, 2016
@aweary
Copy link
Contributor

aweary commented Jul 13, 2016

#7272 adds a warning for this

@mertkahyaoglu
Copy link
Contributor

Also duplicate #7267

@ghost
Copy link

ghost commented Jul 14, 2016

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@gaearon
Copy link
Collaborator

gaearon commented Oct 23, 2016

There is now a warning for this. New docs also mention this now.

@gaearon gaearon closed this Oct 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants