Patched shuffle function to copy array

The inline implementation of shuffle caused React not to detect
changes, because the reference didn't change. Copying the array
with slice(), thus changing the reference, fixed the issue.
This commit is contained in:
datalore 2023-11-16 02:21:52 +01:00
parent 69661a3b12
commit 9f189a9a44

View File

@ -4,6 +4,7 @@ import React from 'react'
import Bingo from './bingo'
function FisherYatesShuffle(array:string[]):string[]{
array = array.slice();
for(let i = array.length - 1; i > 0; i--){
const j = Math.floor(Math.random() * (i + 1));
const temp = array[i];