Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
Función de rebote en el componente funcional react js

Traté de implementar la funcionalidad de rebote en el componente funcional de reacción. Pero debido a alguna razón, no está funcionando.

 import React from "react"; import "./styles.css"; export default function App() { const [random, setRandom] = React.useState(Math.random()); const changeKey = () => { setRandom(Math.random()); }; const debounce = (func, timeout = 1000) => { let timer; return (...args) => { clearTimeout(timer); timer = setTimeout(() => { func.apply(this, args); }, timeout); }; }; return ( <div className="App"> <h1>Hello CodeSandbox</h1> <h2>Start editing to see some magic happen!</h2> <button onClick={() => { debounce(changeKey(), 2000); }} > <p>Click Me!</p> </button> {random} </div> ); }

aquí he agregado el enlace de codesandbox https://codesandbox.io/s/silent-silence-6i532c?file=/src/App.js:0-857

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Considere implementarlo con un gancho. Este, useDebounce de react-use es muy bueno. https://github.com/streamich/react-use/blob/master/docs/useDebounce.md

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!