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

303
Views
Is there similar react componenet with my js code?

I've made some image player by javascript.
I wanna convert this code to react.
Is there any similar react component for this purpose?

var g_image_list = [create_image("http://placekitten.com/148/148"),
create_image("http://placekitten.com/248/248"),
create_image("https://images.squarespace-cdn.com/content/v1/543593e4e4b0bf8b316933e3/1504286897079-V3OLCF6NQ1P06SZSE2G1/image-asset.png")];

var g_index = 0;


function onFrameChange()
{
  var sliderBar = document.getElementById('image_slider');
  var output = document.getElementById('index');
  output.innerText = parseInt(sliderBar.value);
  
  g_index = parseInt(sliderBar.value);
  updateCanvas();
}

function create_image(url){
    var img = new Image();
        img.src = url;
    return img;
}

function updateCanvas(){
    console.log("image loaded");
        drawImage(g_image_list[g_index]);

}

function drawImage(img){
    var ctx = document.querySelector("canvas").getContext("2d");
    ctx.drawImage(img, 0, 0, 500, 500);
}
canvas{
    border: 1px solid black;
}
<canvas width="500" height="500"></canvas>

<div id="index">0</div>

<input type="range" min="0" max="2" class="slider" value="0" id="image_slider" oninput="javascript:onFrameChange();">

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!