npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lazy-input

v2.0.0

Published

A lazy React.js input field that only updates when it is told to re-render (fixes issues with Flux backed field data)

Downloads

45

Readme

lazy-input

npm package Code Climate Test Coverage

A lazy React.js input field that only updates when it is told to re-render (fixes issues with Flux backed field data)

About

Using input elements with Flux can be a pain because actions are asynchronous. Triggering an action in the onChange handler will cause React's default input component to re-render the original value miliseconds before the new value arrives from the store.

LazyInput solves this problem by keeping an internal state for value and only updates that state when given new props, and then only after a lazyLevel has lapsed (default 1s). Otherwise, it works exactly like input. Well, almost. . .

LazyInput expands the type prop slightly to accept textarea in addition to the normal input types. We chose to do it this way because it seemed better than maintaining two packages (LazyInput and LazyTextarea), having lazy-input/input and lazy-input/textarea require statements, or having LazyInput.input and LazyInput.textarea.

var LazyInput = require('lazy-input');
// ...
render: function() {
  return (
    <div>
      // an input element
      <LazyInput type="text" value="some value" onChange={this.onChange} />

      // a test area element
      <LazyInput type="textarea" value="some value" onChange={this.onTextAreaChange} />
    </div>
  );
}

LazyInput can also accept any React Component as the type. For example, if you are using the react-input-placeholder to get placeholder working in older browsers (ex. IE9), then you can pass through the input component directly. There is plenty of rope here to hang yourself though, so be careful.

var Input= PlaceholderShim.input;
// ...
<LazyInput type={Input} value="some value" onChange={this.onChange} />

Installing

Installing via npmjs

npm install --save lazy-input

Using

LazyInput = require('lazy-input');
// ...
<LazyInput type="text" value={this.state.myFluxValue} onChange={this.onChange} />

Examples

git clone https://github.com/HurricaneJames/lazy-input.git
cd lazy-input
npm install
npm run examples
open localhost:8090

Changelog

v2.0 - Updated to support React 15.x, added examples

  • v2.0.0 in theory there is no reason this should not work with React 0.13+, just like before, the only thing that changed was the tests and the addition of examples.

v1.1 - LazyInput types can now include any React Component class. Thanks go to Riku Rouvila.

  • v1.1.1 - fixed bug where html5 descriptive input types crashed (ex. type="tel"). Thanks go to Eric Fennell for reporting the bug.