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

197
Views
How can I convert a wavy line animation in JS to React?

I have implemented this wavy line animation and it works fine, but the problem is that I must convert it to React. I'm pretty new to React, should I use "useState" and "useEffect"?

Here's the code:

let xs = []
for (var i = 0; i < 300; i++) {
  xs.push(i)
}

let t = 0

function animate() {

  let points = xs.map(x => {
   let y = 200 + 8 * Math.sin((x + t) /5)
    
    return [x, y]
  })

  let path = "M" + points.map(p => {
    return p[0] + "," + p[1]
  }).join(" L")

  document.querySelector("path").setAttribute("d", path)

  t += 0.5

  requestAnimationFrame(animate)
}

animate()


<div className="Startpage">
 <svg>
  <path d="M10,10 L50,100 L90,50"></path>
 </svg>
</div>
about 4 years ago · Juan Pablo Isaza
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!