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

109
Vistas
Changing active video in React

I have a video player and a sidebar of other videos to play. I want to be able to to click a video from the sidebar and display it on the video player, replacing the default video, and remove it from the sidebar, putting the replaced video in its place. (The videos are currently just posters as there's no actual video source yet).

Currently, I've set the default video to index 0 from my JSON, and I've set a state that is connected to the sidebar which displays all the videos.

I believe I can use an event listener that takes the id (or index as that's what's being used to display the default video) of the clicked video and uses it to update the active video via the state. However, I'm not sure how to implement this and then hide the active video from the sidebar.

App.js:

class App extends Component {
  state = {
    videos: videos,
    activeVideo: videos[0],
  };

  render(props) {
    return (
      <>
        <Header />
        <VideoPlayer activeVideo={this.state.activeVideo} />
        <LowerSection videos={this.state.videos} />
      </>
    );
  }
}

Video Sidebar:

const NextVideo = (props) => {
  const videos = props.videos;
  return (
    <section className="nextVideosSection">
      <div className="nextVideosSection__content">
        {videos.map((data) => {
          return (
            <>
              <div className="nextVideosSection__image">
                <img
                  className="nextVideosSection__thumbnail"
                  src={data.image}
                  alt="thumbnail"
                />{" "}
              </div>
              <div className="nextVideosSection__text">
                <p className="nextVideosSection__videoTitle">{data.title}</p>
                <p className="nextVideosSection__videoChannel">
                  {data.channel}
                </p>
              </div>
            </>
          );
        })}
      </div>
    </section>
  );
};

JSON format:

{
    "id": "someID",
    "title": "someTitle",
    "channel": "someChannel",
    "image": "someImage.jpg"      //This is used for the video player poster
  },,,
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