Skip to content

Conversation

jblanche
Copy link
Contributor

According to https://facebook.github.io/react/docs/refs-and-the-dom.html

Using the ref callback just to set a property on the class is a common
pattern for accessing DOM elements.
If you are currently using this.refs.myRefName to access refs,
we recommend using this pattern instead.

According to https://facebook.github.io/react/docs/refs-and-the-dom.html
```
Using the ref callback just to set a property on the class is a common
pattern for accessing DOM elements.
If you are currently using this.refs.myRefName to access refs,
we recommend using this pattern instead.
```
@jblanche
Copy link
Contributor Author

Bonus point, this fixes a weird error I was having.

Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs.
You might be adding a ref to a component that was not created inside a component's `render`
method, or you have multiple copies of React loaded
(details: https://fb.me/react-refs-must-have-owner).

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 90.566% when pulling d19d702 on jblanche:newRefSyntax into a727336 on react-component:master.

@benjycui
Copy link
Member

We had discussed this in antd.

It will be a breaking change.

@SomeoneWeird
Copy link

+1

@afc163 afc163 merged commit e298b57 into react-component:master Jan 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants