const returnShuffledArr = (arr) => arr.sort(() => 0.5 - Math.random())
function Component() {
const [arrayState, setArrayState] = React.useState([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
const onClickHandler = () => {
const shuffledArr = returnShuffledArr(arrayState)
setArrayState([...shuffledArr])
}
return (
<>
<div>{JSON.stringify(arrayState)}</div>
<button onClick={onClickHandler}>Shuffle</button>
</>
)
}