Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce 'ref' with string argument #132

Closed
nippur72 opened this issue May 17, 2016 · 1 comment
Closed

Reintroduce 'ref' with string argument #132

nippur72 opened this issue May 17, 2016 · 1 comment

Comments

@nippur72
Copy link
Contributor

With React 15, support for ref and constant string has been dropped:

React-specific properties on DOM refs (e.g. this.refs.div.props) were deprecated, and are removed now. (@jimfb in facebook/react#5495)

I propose to reintroduce it in react-templates, because it's particularly useful when working with templates, since the alternatives/workarounds are rather clumsy.

It could be either an extension of the existing ref or a new rt-ref.

Example:

<div>
   <input rt-ref="myinput" />
</div>

would make the input tag available as this.myinput.

In practice the rt-ref would be turned into a ref using the following transformation:

'ref': (function(r) {this['myinput']=r}).bind(this)
@nippur72
Copy link
Contributor Author

Apparently I was wrong (or perhaps they dropped emitting the warning) but the ref string attribute is still valid in react though now considered "legacy".

From the react docs:

The ref String Attribute
Note: Although string refs are not deprecated, they are considered legacy, and will likely be deprecated at some point in the future. Callback refs are preferred.

So closing this for now, will reopen it in case they'll drop the feature.

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

No branches or pull requests

1 participant