CircleCI Commit

This commit is contained in:
Wiktor Smaga
2023-12-14 14:42:23 +01:00
committed by Wenszel
parent b8e5c564dd
commit 4e404c8320
4 changed files with 45 additions and 8 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ const Gameboard = () => {
setTime(data.nextMoveTime);
setStarted(data.started);
});
}, [socket]);
}, [socket, context.playerId, context.roomId, setRolledNumber]);
return (
<>
@@ -1,4 +1,4 @@
import React, { useState, useContext, useEffect, useCallback } from 'react';
import React, { useState, useContext, useEffect } from 'react';
import { SocketContext } from '../../../App';
import useInput from '../../../hooks/useInput';
import useKeyPress from '../../../hooks/useKeyPress';
+9 -6
View File
@@ -1,10 +1,13 @@
import { useEffect } from 'react';
import { useEffect, useCallback } from 'react';
export default function useKeyPress(targetKey, callback) {
const keyPressHandler = ({ key }) => {
if (key === targetKey) {
callback();
}
};
const keyPressHandler = useCallback(
({ key }) => {
if (key === targetKey) {
callback();
}
},
[targetKey, callback]
);
useEffect(() => {
window.addEventListener('keydown', keyPressHandler);