Created with CodeSandbox
Challenge 3 of 4: Scrolling an image carousel
This image carousel has a “Next” button that switches the active image. Make the gallery scroll horizontally to the active image on click. You will want to call scrollIntoView() on the DOM node of the active image:
Forked from: https://react.dev/learn/manipulating-the-dom-with-refs#scrolling-an-image-carousel
Manage a list of refs with a ref-callback: https://react.dev/learn/manipulating-the-dom-with-refs#how-to-manage-a-list-of-refs-using-a-ref-callback