1. use-throttled-effect
Throttled effect hook for react
use-throttled-effect
Package: use-throttled-effect
Created by: samanmohamadi
Last modified: Sun, 22 May 2022 22:45:21 GMT
Version: 0.0.7
License: MIT
Downloads: 863
Repository: https://github.com/samanmohamadi/use-throttled-effect

Install

npm install use-throttled-effect
yarn add use-throttled-effect

useThrottledEffect react hook

Install it with yarn:

yarn add use-throttled-effect --save

Or with npm:

npm i use-throttled-effect --save

#Example

 import React, { useState } from 'react';
import useThrottledEffect  from 'use-throttled-effect';

export default function Input() {
  const [count, setCount] = useState(0);

  useEffect(()=>{
    const interval = setInterval(() => setCount(count=>count+1) ,100);
    return ()=>clearInterval(interval);
  },[])
  
  useThrottledEffect(()=>{
    console.log(count);     
  }, 1000 ,[count]);
  
  return (
    {count}
  );
}

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code