From 4e404c83209019c9c3fd4df7a3fc39687144279c Mon Sep 17 00:00:00 2001 From: Wiktor Smaga Date: Thu, 14 Dec 2023 14:42:23 +0100 Subject: [PATCH] CircleCI Commit --- .circleci/config.yml | 34 +++++++++++++++++++ src/components/Gameboard/Gameboard.jsx | 2 +- .../LoginPage/NameInput/NameInput.jsx | 2 +- src/hooks/useKeyPress.js | 15 ++++---- 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..ac9ca05 --- /dev/null +++ b/.circleci/config.yml @@ -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 diff --git a/src/components/Gameboard/Gameboard.jsx b/src/components/Gameboard/Gameboard.jsx index 99384ac..4265386 100644 --- a/src/components/Gameboard/Gameboard.jsx +++ b/src/components/Gameboard/Gameboard.jsx @@ -47,7 +47,7 @@ const Gameboard = () => { setTime(data.nextMoveTime); setStarted(data.started); }); - }, [socket]); + }, [socket, context.playerId, context.roomId, setRolledNumber]); return ( <> diff --git a/src/components/LoginPage/NameInput/NameInput.jsx b/src/components/LoginPage/NameInput/NameInput.jsx index 137b026..b34dca6 100644 --- a/src/components/LoginPage/NameInput/NameInput.jsx +++ b/src/components/LoginPage/NameInput/NameInput.jsx @@ -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'; diff --git a/src/hooks/useKeyPress.js b/src/hooks/useKeyPress.js index 70e4a19..1be22b8 100644 --- a/src/hooks/useKeyPress.js +++ b/src/hooks/useKeyPress.js @@ -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);