Closed mircealungu closed 1 month ago
What would be the benefit of using a Img component vs a HTML <img>
element?
I think to resolve the issue of the import the getStaticPath(folder, file)
would make all the calls just src={_getStaticPath("images", "volume_up.svg")}
- would that be better?
The concatenation of the path is done in the component itself, so only once, as opposed to doing it in every <img>
. Do you see what I mean? If not, maybe I should just do it myself and show instead of tell :)))
I think I understand, but I am more thinking that we also will have images that are not in the public folder, so it's a very specific wrapper. So maybe calling it a more specific name like StaticImg
or something similar would make more sense. However, we would still have to specify different folders so it's just the first path that we be saving from altering every time and at that point I don't see the different between a method or a component.
We're using the
APP_DOMAIN + 'static/...'
too much in the code. Two examples are:or
We always have to construct the path to the image.
I see two alternatives:
Img
component that can be used something like<Img source="images/info-icon" width={...
component. It takes a src, concatenates the src path, and passes all the other components to the actualimg
. (Or, probably create a separateImg
andIcon
components for simplicity of writing and reading code?)static_path
that does the concatenation.I think the first is a bit more elegant.