Skip to content

sameterdem/react-debouncing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>
    );
  }
}

About

A React debounce functions. Useful for implementing behavior that should only happen after a repeated action has completed.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published