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...