The PlayMedia 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 to mount PlayMedia at '/media/:mediaId'.
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 using the loadMedia function based on the media ID parameter in the route link.
mern-mediastream/client/media/PlayMedia.js:
loadMedia = (mediaId) => { read({mediaId: mediaId}).then((data) ...