Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
Speech recognition problem in react state

I have a problem with a library react-speech-recognition . newcontent is a state when modify this state inside useeffect print undefined and I also want modify this state for transcript also print undefined

const Room = () => {
let{
    transcript,
  } = useSpeechRecognition();
 
  const [newContent,setnewcontent]=useState('')
}
console.log(transcript)-->//here successful
 useEffect(() => {
console.log(transcript)-->//here undefined
    setnewcontent(transcript)  
console.log(setnewcontent)-->//here undefined  
},[])

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use 2 separate useEffect. One to update the state and other to keep track on it and do the console.log as follows.

// This useEffect will trigger if any change detected in transcript variable
useEffect(() => {
    setnewcontent(transcript)    
},[transcript])

// This useEffect will trigger if any change detected in newContent state
useEffect(() => { 
    console.log(newContent)
},[newContent])
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda