Skip to content

Commit

Permalink
5.9. Подключит HOC в GameScreen.
Browse files Browse the repository at this point in the history
Воспользуемся HOC `withActivePlayer` в компоненте `GameScreen`.
Подключим HOC, создадим обёртки (`GenreQuestionScreenWrapped`,
`ArtistQuestionScreenWrapped`) и воспользуемся ими.
  • Loading branch information
kam4atka authored and AntonovIgor committed Dec 1, 2023
1 parent c21a06e commit 1cd2a8c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pages/game-screen/game-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import {AppRoute, GameType, FIRST_GAME_STEP} from '../../const';
import ArtistQuestionScreen from '../artist-question-screen/artist-question-screen';
import GenreQuestionScreen from '../genre-question-screen/genre-question-screen';
import {QuestionArtist, QuestionGenre, Questions} from '../../types/question';
import withAudioPlayer from '../../hocs/with-audio-player/with-audio-player';

const ArtistQuestionScreenWrapped = withAudioPlayer(ArtistQuestionScreen);
const GenreQuestionScreenWrapped = withAudioPlayer(GenreQuestionScreen);

type GameScreenProps = {
questions: Questions;
Expand All @@ -21,15 +25,15 @@ function GameScreen({questions}: GameScreenProps): JSX.Element {
switch (question.type) {
case GameType.Artist:
return (
<ArtistQuestionScreen
<ArtistQuestionScreenWrapped
key={step}
question={question as QuestionArtist}
onAnswer={() => setStep((prevStep) => prevStep + 1)}
/>
);
case GameType.Genre:
return (
<GenreQuestionScreen
<GenreQuestionScreenWrapped
key={step}
question={question as QuestionGenre}
onAnswer={() => setStep((prevStep) => prevStep + 1)}
Expand Down

0 comments on commit 1cd2a8c

Please sign in to comment.