I am trying to move the first item of an array to the last position of the array in React, using a setInterval
function:
const [cardOrder, setCardOrder] = useState([card1, card2, card3, card4]);
setInterval(() => {
setCardOrder(cards.push(cards.shift()))
}, 3000);
The first time always works, but the second time I get
TypeError: cardsOrder.shift is not a function
How can I achieve this result? All help appreciated. Thanks.