I created a React application that manipulates an array of letters by shifting and unshifting them. The transition animation is triggered when the user clicks on the next
and back
buttons. Although the array is modified correctly, the transition effect only works when clicking next
. I suspect that this issue might be related to something fundamental rather than specific to React, although I have ensured that the key is unique to prevent re-rendering.
// here's where the problem lies.
clickLeftRightHandler = () => {
const { list } = this.state;
// Could redrawing occur due to using slice or shifting the array? Or is it related to CSS?
const newList = [list[list.length-1], ...list.slice(0, -1)];
this.setState({list : newList});
}
Link to Code: https://stackblitz.com/edit/react-7nsrjg
Any assistance would be greatly appreciated!