-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Implement valueLink and checkedLink #131
Comments
Hey @slorber, thanks for the time writing up with detail the issues you've submitted. (However I may go through them a little slowly - other OSS projects need some love and so does my main-work project :S) My initial reaction to something like this is concern for type-safety, or rather, correctness provable by the compiler. If we were to implement something like this we'd want to ensure that the ...which is think is doable, but I foresee it being a potentially significant amount of work. Maybe I'll give it a try on a branch sometime and see how it goes. Lens & prisms to tags could be a very good thing but tags' attributes determine the content type as much as tags themselves (eg. |
I understand your point. Actually I think it could be simpler: valueLink takes an |
Yeah that was what I was originally thinking (avoiding I was also thinking what specifically does this buy us? I guess it gives us 2 two things:
Do you think it's worth it? I'm on the fence. Push me over it! Also note to future self: add contramap to |
I think this is exactly what you think it is: a syntactic sugar :) Check the documentation: https://facebook.github.io/react/docs/two-way-binding-helpers.html var WithLink = React.createClass({
mixins: [React.addons.LinkedStateMixin],
getInitialState: function() {
return {message: 'Hello!'};
},
render: function() {
return <input type="text" valueLink={this.linkState('message')} />;
}
}); var WithoutMixin = React.createClass({
getInitialState: function() {
return {message: 'Hello!'};
},
handleChange: function(newValue) {
this.setState({message: newValue});
},
render: function() {
var valueLink = {
value: this.state.message,
requestChange: this.handleChange
};
return <input type="text" valueLink={valueLink} />;
}
}); Both are equivalent. As you can see the behavior is very simple The |
Thanks @slorber. I am convinced :) I'll get this done. |
As an additional note - if not already considered, it would be awesome if this could be written to an interface and not hardcoded to
I have a custom |
Aye, rest assured, I was thinking the same. There will be an open interface On 29 June 2015 at 12:55, James notifications@github.com wrote:
|
Note: This doesn't mean we have to care but I'd be interested in knowing why. |
@japgolly the issue seems to be facebook/react#2302 |
This feature still holds some appeal but when one thinks about it logically, we're talking about adding an abstracting so allow you to specify one vdom attribute instead of two. Given some of the major themes of the 1.0 rewrite were simplicity, transparency and readability, it's clear that it's not worth it. Let's just continue specifying two attributes every now and then and have it be clear how it all works. |
I did not found valueLink and checkedLink in the list of available Html attributes.
https://facebook.github.io/react/docs/two-way-binding-helpers.html
Note that you can easily do 2-way data binding on a lens with valueLink.
I've done it here: https://github.com/stample/atom-react/blob/master/src/atomReact.js
Usage here: https://github.com/stample/atom-react/blob/master/examples/todomvc/js/components/TodoTextInput.react.js#L30
I think your ExternalVar example could be rewritten with a syntax like:
The text was updated successfully, but these errors were encountered: