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 eb1e1c0..64c81f1 100644 --- a/src/components/Gameboard/Gameboard.jsx +++ b/src/components/Gameboard/Gameboard.jsx @@ -58,6 +58,7 @@ const Gameboard = () => { socket.on('redirect', () => { window.location.reload(); }); + }, [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);