1.0.3 • Published 4 years ago

react-debouncing v1.0.3

Weekly downloads
114
License
ISC
Repository
github
Last release
4 years ago

Installation

$ npm install react-debouncing

Or :

$ yarn add react-debouncing

Example

import React, { Component } from 'react';
import debounce from 'react-debouncing';

class Debounce extends Component {
  state = {
    count: 0,
  };

  increment = debounce(() => {
    this.setState({
      count: this.state.count + 1,
    });
  }, 500);

  decrement = debounce(() => {
    this.setState({
      count: this.state.count - 1,
    });
  }, 500);

  render() {
    return (
      <div>
        <div>{this.state.count}</div>
        <button onClick={this.increment}> + </button>
        <button onClick={this.decrement}> - </button>
      </div>
    );
  }
}