Merge branch 'main' into dev

This commit is contained in:
Wiktor Smaga 2023-12-19 11:41:17 +01:00 committed by GitHub
commit f07c1c8577
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 7 deletions

34
.circleci/config.yml Normal file
View File

@ -0,0 +1,34 @@
version: 2.1
jobs:
build_and_test:
docker:
- image: circleci/node:14
working_directory: ~/app
steps:
- checkout
- run:
name: Install Frontend Dependencies
command: |
npm install
- run:
name: Install Backend Dependencies
command: |
cd backend
npm install
- run:
name: Build Frontend
command: |
npm run build
- run:
name: Test Frontend
command: |
npm test
workflows:
version: 2
build:
jobs:
- build_and_test

View File

@ -58,6 +58,7 @@ const Gameboard = () => {
socket.on('redirect', () => { socket.on('redirect', () => {
window.location.reload(); window.location.reload();
}); });
}, [socket, context.playerId, context.roomId, setRolledNumber]); }, [socket, context.playerId, context.roomId, setRolledNumber]);
return ( return (

View File

@ -1,4 +1,4 @@
import React, { useState, useContext, useEffect, useCallback } from 'react'; import React, { useState, useContext, useEffect } from 'react';
import { SocketContext } from '../../../App'; import { SocketContext } from '../../../App';
import useInput from '../../../hooks/useInput'; import useInput from '../../../hooks/useInput';
import useKeyPress from '../../../hooks/useKeyPress'; import useKeyPress from '../../../hooks/useKeyPress';

View File

@ -1,10 +1,13 @@
import { useEffect } from 'react'; import { useEffect, useCallback } from 'react';
export default function useKeyPress(targetKey, callback) { export default function useKeyPress(targetKey, callback) {
const keyPressHandler = ({ key }) => { const keyPressHandler = useCallback(
if (key === targetKey) { ({ key }) => {
callback(); if (key === targetKey) {
} callback();
}; }
},
[targetKey, callback]
);
useEffect(() => { useEffect(() => {
window.addEventListener('keydown', keyPressHandler); window.addEventListener('keydown', keyPressHandler);