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

Drop ReactLink hooks in controlled components #2302

Closed
sebmarkbage opened this issue Oct 7, 2014 · 10 comments
Closed

Drop ReactLink hooks in controlled components #2302

sebmarkbage opened this issue Oct 7, 2014 · 10 comments

Comments

@sebmarkbage
Copy link
Collaborator

ReactLink supports a sort of adhoc two-way data binding. We've found it to be a distraction rather than helpful so we don't plan on adding it to the core outside of addons anyway.

We should take the support out of controlled components and make wrappers that can be used instead of the controlled components, and put the wrappers in addons. This provides backwards compatibility without having the legacy remain in core.

@syranide
Copy link
Contributor

syranide commented Oct 8, 2014

👍

@syranide
Copy link
Contributor

syranide commented Oct 8, 2014

This should be rather trivial, should I draft a PR?

@syranide syranide closed this as completed Oct 8, 2014
@syranide syranide reopened this Oct 8, 2014
@zpao
Copy link
Member

zpao commented Oct 8, 2014

Yo @petehunt this was your jam. Any opinions?

@ThomasCrevoisier
Copy link
Contributor

@sebmarkbage Could you give examples of wrappers needed ? (I'm new to the contribution in React, sorry if I ask trivial questions ^^')

@ThomasCrevoisier
Copy link
Contributor

Any clues ?

@saulshanabrook
Copy link

@sebmarkbage Could you give an example of how to best deal with multiple form inputs without linkState?

@syranide
Copy link
Contributor

@saulshanabrook

The two following are equivalent, it's just sugar really.
<input valueLink={vl} />
<input value={vl.value} onChange={vl.requestChange} />

https://github.com/facebook/react/blob/master/src/addons/link/LinkedStateMixin.js
https://github.com/facebook/react/blob/master/src/addons/link/ReactLink.js

@tobia
Copy link

tobia commented May 19, 2015

ReactLink may be "just sugar really," but when you have dozens of inputs in a form and hundreds in the entire application, it makes a noticeable difference. JSX itself is "just sugar really," but it's an important tool for productivity and readability.

Compare:

<input valueLink={this.linkState("surname")} />
<input value={this.linkState("surname").value} onChange={this.linkState("surname").requestChange} />

That being said, I'm all for taking ReactLink out of core, _if_ the syntax doesn't explode like in the example above.

@syranide
Copy link
Contributor

@tobia Like I mention in #3591, you can wrap an input in your own component of your own which can provide the same functionality (and more). If/when it's dropped React would certainly provide such wrappers out-of-the-box in addons, but it wouldn't really be special or anything you can't already do yourself.

@gaearon
Copy link
Collaborator

gaearon commented Apr 21, 2017

This was fixed in #8165.

@gaearon gaearon closed this as completed Apr 21, 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

No branches or pull requests

7 participants