Animate the carousel like Carousel II, but keep the DOM footprint minimal: render only the current slide instead of all N. For heavy slides (real images), holding every one in the DOM is wasteful — so render one, and replay a CSS enter animation each time the slide changes by remounting it with a key.
// A self-contained component. No props.
function App(): JSX.Element;
A viewport that holds exactly one slide, animating each change.
Next -> slide remounts (key = index) -> enters from the right
Prev -> slide remounts -> enters from the left
the DOM always contains one .slide, regardless of how many slides exist
SLIDES[index] only — not a track of all of them.key={index} makes React unmount the old slide and mount the new, replaying its CSS animation.@keyframes slide-in animates the single mounted slide.Unlock the solution & editor
Runnable editor + tests
Solve in the browser with instant Jest feedback.
Detailed solutions
Walkthroughs, edge cases, and complexity notes.
Multi-framework variants
React, Vue, Vanilla, Angular — same question, different stacks.