Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!