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

81
Views
How to copy a image from React to a carousel slide

I made a carousel slide that moves from index (0 ~ length). I want to do a slide that moves indefinitely. Can I ask for your advice?

React js

  const IMAGE = 1084;
  const slideRef = useRef();
  const [index, setIndex] = useState(0);

  const prevIsCardHandler = () => {
    if (index === 0) {
      return;
    }
    setIndex(prev => prev - 1);
    slideRef.current.style.transform = `translateX(-${IMAGE * (index - 1)}px)`;
  };

  const nextIsCardHandler = () => {
    if (SLIDE_CARD_DATA.length - 1 === index) {
      return;
    } else {
      setIndex(prev => prev + 1);
      slideRef.current.style.transform = `translateX(-${
        IMAGE * (index + 1)
      }px)`;
    }
  };

  <CardWrap ref={slideRef}>
    {SLIDE_CARD_DATA.map(data => {
    return (
     <Card key={data.id} style={{ backgroundImage: `url(${data.src})` }} />
          );
        })}
  </CardWrap>
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!