From 9f189a9a446cf6d341342aef0aa03fd8dff64f8d Mon Sep 17 00:00:00 2001 From: datalore Date: Thu, 16 Nov 2023 02:21:52 +0100 Subject: [PATCH] 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. --- src/app/components/bingocontroller.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/components/bingocontroller.tsx b/src/app/components/bingocontroller.tsx index d3857a4..5461e46 100644 --- a/src/app/components/bingocontroller.tsx +++ b/src/app/components/bingocontroller.tsx @@ -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];