-
Preliminary Checks
DescriptionTitle might do a poor job of explaining what the issue is about. Ignore it and also, Forgive my poor explanation skills. I discovered this issue when I was using {
"image-root": "images/",
"someData": [
{
"name": "doggy",
"image": "puppy.png"
},
{
"name": "Cat",
"image": "meow.png"
}
]
} Since, the files in static folder are directly moved to build output. So, class IndexPage extends React.Component {
render() {
let CardsWithData = data.someData.map((x) => {
x.image = data["image-root"] + x.image;
//check the browser console after making a change in this file
//Multiple string additions happen here. But when page is reloaded it works fine.
console.log(x.image);
return <Cards key={x.name} data={x} />;
});
return <div>{CardsWithData}</div>;
}
} Reproduction Linkhttps://github.com/U-C-S/Gatsby-Bug-Reproduce Steps to Reproduce
Expected ResultActual ResultThe path keeps on adding themselves for every change that's made. I believe this is a issue due to improper cache The issue occurs for other strings, numbers ...... EnvironmentSystem:
OS: Windows 10 10.0.19043
CPU: (8) x64 Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz
Binaries:
Node: 16.4.2 - C:\Program Files\nodejs\node.EXE
npm: 7.18.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1023.0), Chromium (91.0.864.70)
npmPackages:
gatsby: ^3.9.1 => 3.9.1 Config FlagsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! This is not a problem with Gatsby but your code. You're mutating the value that you're then later use: let imgPath = data["image-root"] + x.image;
x.image = imgPath; You also might be missing a leading slash in front of the URL. Please see these docs for further reference: |
Beta Was this translation helpful? Give feedback.
Hi!
This is not a problem with Gatsby but your code. You're mutating the value that you're then later use:
You also might be missing a leading slash in front of the URL.
Please see these docs for further reference: