New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-async-input

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-async-input

wrap React inputs so that asynchrous updates don't cause the cursor to jump

latest
Source
npmnpm
Version
0.9.2
Version published
Weekly downloads
6
20%
Maintainers
1
Weekly downloads
 
Created
Source

react-async-input

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

Warning! Not Perfect!

Under very rapid keyboard input and/or network jitter conditions, this will still fail to do what you want. See these two fiddles for more:

http://jsfiddle.net/yrmmbjm1/1/

http://jsfiddle.net/yrmmbjm1/4/

I hope to work out a better way to handle all of this soon.

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)

Keywords

react

FAQs

Package last updated on 16 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts