From 9e7aec25ea85535d0200520d07b653a1cbdab68c Mon Sep 17 00:00:00 2001 From: myroslav Date: Wed, 23 Nov 2022 22:19:26 +0200 Subject: [PATCH] add: prop to sound interval --- src/components/Card/Card.jsx | 1 + src/components/SoundInterval/SoundInterval.jsx | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Card/Card.jsx b/src/components/Card/Card.jsx index 379b598..9173526 100644 --- a/src/components/Card/Card.jsx +++ b/src/components/Card/Card.jsx @@ -126,6 +126,7 @@ function Card() { onWord={word} onIndexWord={indexWord} currentLanguage={currentLanguage} + stateForSwitchWord={stateForSwitchWord} /> {word.length > 0 && ( diff --git a/src/components/SoundInterval/SoundInterval.jsx b/src/components/SoundInterval/SoundInterval.jsx index 5aef69a..966db8d 100644 --- a/src/components/SoundInterval/SoundInterval.jsx +++ b/src/components/SoundInterval/SoundInterval.jsx @@ -5,7 +5,12 @@ import { useState, useEffect } from 'react'; let myCounter = 0; let timeout = null; -const SoundInterval = ({ onWord, onIndexWord, currentLanguage }) => { +const SoundInterval = ({ + onWord, + onIndexWord, + currentLanguage, + stateForSwitchWord, +}) => { const [counter, setCounter] = useState(0); const [togle, setTogle] = useState(false); console.log(onWord.length); @@ -28,15 +33,12 @@ const SoundInterval = ({ onWord, onIndexWord, currentLanguage }) => { }; // логіка кнопки озвучування const handleClickSound = c => { - // setTogle(prev => !prev); - // console.log(c); - // e.preventDefault(); let soundWordIndex = onWord.filter((el, idx) => idx === c); const synth = window.speechSynthesis; // зупинемо все, що вже синтезується раніше synth.cancel(); - console.log('hallo', soundWordIndex); + // читання тексту const utterance = new SpeechSynthesisUtterance(soundWordIndex[0].en); if (currentLanguage === 'en') {