GitXplorerGitXplorer
g

react-async-input

public
5 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
6b87e5cd1ec6a41f96e90766ac98f685a105ae90

Merge pull request #3 from drd/master

ggrncdr committed 10 years ago
Unverified
3f037d5faadcc07f9b809485b178b4adfbfc5ce9

switch react to be a peer dependency; bump version

ddrd committed 10 years ago
Unverified
ac4c57d3c8c71c6dd6a2d00da73089159c0d96b4

Update asyncInput to work with modern React

committed 10 years ago
Unverified
c1de10d162b925e47251db65dd962afc3c967b9e

I guess it does work on React 0.11.2 (closes #2)

ggrncdr committed 10 years ago
Unverified
9747bd13420ec7f1eb88343f5d06ac2313c5f52a

Add unmaintained warning.

ggrncdr committed 10 years ago
Unverified
eca48f146596c5628f641ee5bd6170ea0d53ee42

0.9.0

ggrncdr committed 11 years ago

README

The README file for this repository.

react-async-input

Wrap React inputs so that asynchrous updates don't cause the cursor to jump around.

Warning! Old and unmaintained!

I haven't been keeping up with React/maintaining anything that uses it, so this library is compatible with React 0.9.x. It may or may not work with new versions of React. If you use React and this library, send a PR and I will grant you ownership of the package on npm.

Synopsis

var DOM = require('react').DOM
var asyncInput = require('react-async-input')

var input = asyncInput(DOM.input)

// Or monkey-patch React.DOM, don't do this in a library!
// asyncInput.monkeyPatch(DOM)

react.createClass({
  getInitialState: function () {
    this.setState({name: 'Jerry! Sizzlah!'})
  },

  render: function () {
    return DOM.div(null, [
      DOM.label(null, 'Name:'),
      input({
        type: 'number',
        value: this.state.name,
        onChange: this.handleNameChange
      })
    ])
  },

  // this asynchronous event handler no longer causes the cursor to jump around
  handleNameChange: function (event) {
    process.nextTick(function () {
      this.setState({name: event.target.value})
    }.bind(this))
  }
})

Acknowledgements

I copied this technique from swannodette/om after dnolen told me about it. All credit to him for solving a problem I didn't know I was going to have before I even had it.

License

Licensed under the EPL (same as Om)