Why not load the module when you use the require?

Good day to all.
Trying to understand why it may not work this code:
useEffect(() => {
 setPagesList(config.pages.map(page => {
 return require(`${page.path}`);
 }, []);

where page is the object of the kind {path: '../../data/data2.md', title: "Chapter 2"},
If I pass the string:
return require('../../data/data2.md',);
Then everything works fine. The same effect when using dynamic imports.

The error text:
Error: Cannot find module '../../data/data2.md'
April 3rd 20 at 18:50
0 answer

Find more questions by tags React