Reader small image

You're reading from  Full-Stack React Projects. - Second Edition

Product typeBook
Published inApr 2020
Reading LevelBeginner
PublisherPackt
ISBN-139781839215414
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Shama Hoque
Shama Hoque
author image
Shama Hoque

Shama Hoque has 8 years of experience as a software developer and mentor, with a Master's in Software Engineering from Carnegie Mellon University. From Java programming to full-stack development with JavaScript, the applications she has worked on include national Olympiad registration websites, universally accessible widgets, video conferencing apps, and medical 3D reconstruction software. Currently, she makes web-based prototypes for R&D start-ups in California, while training aspiring software engineers and teaching web development to CS undergrads in Bangladesh.
Read more about Shama Hoque

Right arrow

The PlayMedia component

The PlayMedia component will render the play media page. This component consists of the Media and RelatedMedia child components along with an autoplay toggle, and it provides data to these components when it loads in the view.

To render the PlayMedia component when individual media links are accessed by the user, we will add a Route in MainRouter and mount PlayMedia at '/media/:mediaId', as follows:

mern-mediastream/client/MainRouter.js

<Route path="/media/:mediaId" component={PlayMedia}/>

When the PlayMedia component mounts, it will fetch the media data and the related media list from the server with useEffect hooks based on the mediaId parameter in the route link.

In one useEffect hook, it will fetch the media to be loaded in the media player, as shown in the following code:

mern-mediastream/client/media/PlayMedia.js

useEffect...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Full-Stack React Projects. - Second Edition
Published in: Apr 2020Publisher: PacktISBN-13: 9781839215414

Author (1)

author image
Shama Hoque

Shama Hoque has 8 years of experience as a software developer and mentor, with a Master's in Software Engineering from Carnegie Mellon University. From Java programming to full-stack development with JavaScript, the applications she has worked on include national Olympiad registration websites, universally accessible widgets, video conferencing apps, and medical 3D reconstruction software. Currently, she makes web-based prototypes for R&D start-ups in California, while training aspiring software engineers and teaching web development to CS undergrads in Bangladesh.
Read more about Shama Hoque