I have an app which loads data from a json. That data could be a video, in which case it's rendered the next component:
export default function Video({ video }) {
return (
<>
<video controls width="100%">
<source src={require(video)} type="video/mp4" />
</video>
</>
);
}
The param video has the path to the video, it's supossed to be located in a local folder on my app. When I try to render the component Video with a valid param, I obtain the next error:
Uncaught Error: Cannot find module 'static/content/sample_video.mp4'
Meanwhile, when I try to get the video directly from a string like this: `
<source src={require("static/content/sample_video.mp4")} type="video/mp4" />
The video is rendered correctly. The parameter video has exactly the same string that I'm hardcoding in the require.
What should I do to render my video using the parameter?