I\'m using the state variable to keep track of my previous state.
The animation works (without index), but when I do
const [index, setIndex] = useState