2 Commits

Author SHA1 Message Date
487f5f854e Updated version to 0.3.1 2023-11-16 02:42:04 +01:00
9f189a9a44 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.
2023-11-16 02:21:52 +01:00
3 changed files with 4 additions and 3 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "buzzword-bingo", "name": "buzzword-bingo",
"version": "0.3.0", "version": "0.3.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "buzzword-bingo", "name": "buzzword-bingo",
"version": "0.3.0", "version": "0.3.1",
"dependencies": { "dependencies": {
"next": "14.0.1", "next": "14.0.1",
"react": "^18", "react": "^18",

View File

@@ -1,6 +1,6 @@
{ {
"name": "buzzword-bingo", "name": "buzzword-bingo",
"version": "0.3.0", "version": "0.3.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

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