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

194
Vistas
React player not updating className on state change

I'm building an app that adds a stream whenever a user searches for one (up to four players on a page). I want to change the styling based on how many players I have. I'm using my searchedStreams state. length as a condition. My issue is that after a second stream is searched the wrapper class is updated properly but the ReactPlayer className on the first player does not update.

const ctx = useContext(ThemeContext);
  const stylesWrapper = `${
    ctx.searchedStreams.length === 1 ? `${classes.wrapperOneStream}` : ""
  } ${ctx.searchedStreams.length === 2 ? `${classes.wrapperTwoStreams}` : ""}${
    ctx.searchedStreams.length === 3 ? `${classes.wrapperThreeStreams}` : ""
  }`;
  const stylesPlayer = `${
    ctx.searchedStreams.length === 1 ? `${classes.player1}` : ""
  } ${ctx.searchedStreams.length === 2 ? `${classes.player2}` : ""} ${
    ctx.searchedStreams.length === 3 ? `${classes.player3}` : ""
  }`;

  return (
    <Fragment>
      {ctx.searchedStreams.map((label) => (
        <div className={stylesWrapper} key={label}>
          <ReactPlayer
            key={label}
            className={stylesPlayer}
            url={`https://www.twitch.tv/${label}`}
            width="100%"
            theme="dark"
            playing={true}
          />
        </div>
      ))}
    </Fragment>
  );

enter image description here

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