diff --git a/client/src/components/common/ScoreChart.js b/client/src/components/common/ScoreChart.js index 36ec331f..4ce99107 100644 --- a/client/src/components/common/ScoreChart.js +++ b/client/src/components/common/ScoreChart.js @@ -119,21 +119,24 @@ function ScoreChart({ itemDatas }) { }, []); return ( - {items.map((item, index) => ( - - - {item.title} - - - - - {item.playerCount} - - - - - - ))} + {items.map((item, index) => { + if (!item.title) return null; + return ( + + + {item.title} + + + + + {item.playerCount} + + + + + + ); + })} ); } diff --git a/client/src/components/edit/Section.js b/client/src/components/edit/Section.js index 18a641b5..6ca1d174 100644 --- a/client/src/components/edit/Section.js +++ b/client/src/components/edit/Section.js @@ -56,6 +56,7 @@ function Section({ roomId, quizsetId }) { const { quizset } = result.data; dispatch({ type: actionTypes.READ_QUIZSET, quizset }); } + dispatch({ type: actionTypes.RESET_DELETE_QUIZZES }); dispatch({ type: actionTypes.UPDATE_IDS, roomId, quizsetId }); diff --git a/client/src/components/edit/SideBar.js b/client/src/components/edit/SideBar.js index 8108a6e9..52069f0a 100644 --- a/client/src/components/edit/SideBar.js +++ b/client/src/components/edit/SideBar.js @@ -144,9 +144,14 @@ function SideBar() { } useEffect(() => { - window.addEventListener('resize', () => - setWindowSize({ width: window.innerWidth, height: window.innerHeight }), - ); + function changeWindowSize() { + setWindowSize({ width: window.innerWidth, height: window.innerHeight }); + } + + window.addEventListener('resize', changeWindowSize); + return () => { + window.removeEventListener('resize', changeWindowSize); + }; }, []); useEffect(() => { diff --git a/client/src/components/inGame/HostQuizPlayingRoom.js b/client/src/components/inGame/HostQuizPlayingRoom.js index 988ba2bc..9f2efc44 100644 --- a/client/src/components/inGame/HostQuizPlayingRoom.js +++ b/client/src/components/inGame/HostQuizPlayingRoom.js @@ -70,13 +70,16 @@ function HostQuizPlayingRoom() { - {roomState.currentQuiz.items.map((item, index) => ( - - -

{item.title}

-
-
- ))} + {roomState.currentQuiz.items.map((item, index) => { + if (!item.title) return null; + return ( + + +

{item.title}

+
+
+ ); + })}
diff --git a/client/src/components/inGame/PlayerQuiz.js b/client/src/components/inGame/PlayerQuiz.js index def9ad7d..0c9aab98 100644 --- a/client/src/components/inGame/PlayerQuiz.js +++ b/client/src/components/inGame/PlayerQuiz.js @@ -40,17 +40,20 @@ function Selection({ currentQuiz, chooseAnswer, setIsAnswer }) { - {currentQuiz.items.map((item, index) => ( - - - - ))} + {currentQuiz.items.map((item, index) => { + if (!item.title) return null; + return ( + + + + ); + })} diff --git a/client/src/reducer/hostEditReducer.js b/client/src/reducer/hostEditReducer.js index c7989f98..d0eb5bb3 100644 --- a/client/src/reducer/hostEditReducer.js +++ b/client/src/reducer/hostEditReducer.js @@ -35,6 +35,7 @@ const actionTypes = { DELETE_QUIZ: 10, UPDATE_IDS: 11, CHANGE_LOADING: 12, + RESET_DELETE_QUIZZES: 13, }; const loadingTypes = { @@ -168,6 +169,9 @@ const quizsetReducer = (quizsetState, action) => { case actionTypes.CHANGE_LOADING: { return { ...quizsetState, loadingType: action.loadingType }; } + case actionTypes.RESET_DELETE_QUIZZES: { + return { ...quizsetState, deletedQuizzes: [] }; + } default: return quizsetState; }