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

112
Vistas
why does flushSync do this?

after some research i came with this react function called flushSync, while reading some examples it says it forces every setState inside to be synchronous, but when i implement it to my code the first time i press the checkbox, it checks on the page, but the react state does not update to checked(true boolean), and the second time i press the checkbox, it unchecks but the react state gets checked, so it unsynchronises, am i doing something wrong or is this a normal behavior?

function handleGenre(e) {
        flushSync(() => {
            setState({...state, genres : {...state.genres, [e.target.name]: e.target.checked}})
          });
        Object.values(state.genres).find(e => e === true) ? console.log('si') : console.log('no')
    }
about 4 years ago · Juan Pablo Isaza
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