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:
parent
69661a3b12
commit
9f189a9a44
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user