Импорт модулей с использованием require или импорт модулей с использованием es6
Оператор import используется для импорта привязок, которые экспортируются другим модулем. Импортируемые модули находятся в строгом режиме независимо от того, объявляете ли вы их как таковые или нет. Оператор импорта нельзя использовать во встроенных сценариях.
1. Using Import
import imgPath from '../img' //local path of image in application
render() {
const file1 = {
"name": "xxxxx",
"img": "https://drive.google.com/thumbnail?id=1zeBeWS26cF",
//**"previously I calling the image from google drive now I need to render it from local path.how can I do that ? "**,
"details": "blah blah"
};
const file2 = {
"name": "xxxxx",
"img": imgPath,
//**"previously I calling the image from google drive now I need to render it from local path.how can I do that ? "**,
"details": "blah blah"
};
return (
<div className="bio_mainDiv">
<div className="cards"><BioCard card={file1} /></div> **//So I am not able use <img src="" /> here..**
<div className="cards"><BioCard card={file2} /></div>
</div>
);
}
2. Using require
render() {
const file1 = {
"name": "xxxxx",
"img": "https://drive.google.com/thumbnail?id=1zeBeWS26cF",
//**"previously I calling the image from google drive now I need to render it from local path.how can I do that ? "**,
"details": "blah blah"
};
const file2 = {
"name": "xxxxx",
"img": require('.../img'),
//**"previously I calling the image from google drive now I need to render it from local path.how can I do that ? "**,
"details": "blah blah"
};
return (
<div className="bio_mainDiv">
<div className="cards"><BioCard card={file1} /></div> **//So I am not able use <img src="" /> here..**
<div className="cards"><BioCard card={file2} /></div>
</div>
);
}