Merge pull request #8 from Wenszel/circleci-project-setup

CircleCI Commit
This commit is contained in:
Wiktor Smaga 2023-12-14 15:15:32 +01:00 committed by GitHub
commit b0413ea2d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 8 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

@ -47,7 +47,7 @@ const Gameboard = () => {
setTime(data.nextMoveTime); setTime(data.nextMoveTime);
setStarted(data.started); setStarted(data.started);
}); });
}, [socket]); }, [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);