dillon1000/react

Commit

ReactLink: two-way binding for React

This introduces `ReactLink` which is a super lightweight way to do two-way binding for React.

If you want to use a controlled form input today, it's a lot of lines of code:

http://jsfiddle.net/T3z3v/

Look how many times `name` is repeated in there. And you have to remember to wire up event handles and pass the right state and
right event handler for *each* form field. It's really annoying.

With ReactLink, you can "link" a form value to a state field. It's just some simple sugar around the value prop/onChange
convention:

https://gist.github.com/petehunt/6689857

Ah, much nicer! And requires very little core changes or extra bytes. `ReactLink` just wraps the current value and "request
change" handler into a little object and provides some sugar to create some from composite component state.
Browse files
Changed paths10 files
First-parent comparison
A src/addons/link/LinkedStateMixin.js AddedA src/addons/link/ReactLink.js AddedA src/addons/link/__tests__/LinkedStateMixin-test.js AddedA src/dom/components/LinkedValueMixin.js AddedM src/dom/components/ReactDOMInput.js ModifiedM src/dom/components/ReactDOMSelect.js ModifiedM src/dom/components/ReactDOMTextarea.js ModifiedM src/dom/components/__tests__/ReactDOMInput-test.js ModifiedM src/dom/components/__tests__/ReactDOMSelect-test.js ModifiedM src/dom/components/__tests__/ReactDOMTextarea-test.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…